add env compatibility with DOCKER_ prefixes

This commit is contained in:
Chase Pierce 2020-06-29 19:47:16 -06:00
parent 6ffdd6905f
commit b93f6fad1d
3 changed files with 35 additions and 5 deletions

View file

@ -18,9 +18,9 @@ This is useful if you `docker push` your images to Docker Hub. It provides an ea
#### Required environment variables #### Required environment variables
- `DOCKERHUB_USERNAME` - Docker Hub username. If updating a Docker Hub repository belonging to an organization, this user must have `Admin` permissions for the repository. - `DOCKERHUB_USERNAME` - Docker Hub username. If updating a Docker Hub repository belonging to an organization, this user must have `Admin` permissions for the repository. Aliases: `DOCKER_USERNAME`
- `DOCKERHUB_PASSWORD` - Docker Hub password. - `DOCKERHUB_PASSWORD` - Docker Hub password. Fallback to `DOCKER_PASSWORD` if set. Aliases: `DOCKER_PASSWORD`
- `DOCKERHUB_REPOSITORY` - The Docker Hub repository to update in the format `<namespace>/<name>`. May also be passed as a secret if considered sensitive. - `DOCKERHUB_REPOSITORY` - The Docker Hub repository to update in the format `<namespace>/<name>`. May also be passed as a secret if considered sensitive. Aliases: `DOCKER_REPOSITORY`, `GITHUB_REPOSITORY`
**Note**: Docker Hub [Personal Access Tokens](https://docs.docker.com/docker-hub/access-tokens/) cannot be used as they are not supported by the API. See [here](https://github.com/docker/hub-feedback/issues/1927) and [here](https://github.com/docker/hub-feedback/issues/1914) for further details. Unfortunately, this means that enabling the new 2FA feature on Docker Hub will prevent the action from working. **Note**: Docker Hub [Personal Access Tokens](https://docs.docker.com/docker-hub/access-tokens/) cannot be used as they are not supported by the API. See [here](https://github.com/docker/hub-feedback/issues/1927) and [here](https://github.com/docker/hub-feedback/issues/1914) for further details. Unfortunately, this means that enabling the new 2FA feature on Docker Hub will prevent the action from working.

View file

@ -5,5 +5,15 @@ runs:
using: 'docker' using: 'docker'
image: 'docker://peterevans/dockerhub-description:2.1.1' image: 'docker://peterevans/dockerhub-description:2.1.1'
branding: branding:
icon: 'upload' icon: 'upload'
color: 'blue' color: 'blue'
inputs:
dockerhubUsername:
description: Username to login to Docker Hub. Aliases: DOCKER_USERNAME
required: false
dockerhubPassword:
description: Password to login to Docker Hub. Aliases: DOCKER_PASSWORD
required: false
dockerhubRepository:
description: Explicit Docker Hub repository name. Aliases: DOCKER_REPOSITORY, GITHUB_REPOSITORY
required: false

View file

@ -1,7 +1,27 @@
#!/bin/sh -l #!/bin/sh -l
set -euo pipefail set -eo pipefail
IFS=$'\n\t' IFS=$'\n\t'
# Allow DOCKERHUB_* variables to be set from their DOCKER_* variant
DOCKERHUB_USERNAME=${DOCKERHUB_USERNAME:-${DOCKER_USERNAME}}
DOCKERHUB_PASSWORD=${DOCKERHUB_PASSWORD:-${DOCKER_PASSWORD}}
DOCKERHUB_REPOSITORY=${DOCKERHUB_REPOSITORY:-${DOCKER_REPOSITORY}}
# If the repository isn't explicitly defined, infer it from GitHub if possible
DOCKERHUB_REPOSITORY=${DOCKERHUB_REPOSITORY:-${GITHUB_REPOSITORY}}
# Validate we can authenticate
if [ -z "$DOCKERHUB_USERNAME" ] || [ -z "$DOCKERHUB_PASSWORD" ]; then
echo 'Unable to authenticate with Docker Hub, set a valid $DOCKERHUB_USERNAME and $DOCKERHUB_PASSWORD'
exit 1
fi
# Validate we have the repository name
if [ -z "$DOCKERHUB_REPOSITORY" ]; then
echo 'Unable to determine Docker Hub repository name, set with $DOCKERHUB_REPOSITORY'
exit 1
fi
# Set the default path to README.md # Set the default path to README.md
README_FILEPATH=${README_FILEPATH:="./README.md"} README_FILEPATH=${README_FILEPATH:="./README.md"}