Merge pull request #12 from syntaqx/feature/env-compatibility

Compatibility with configuration sources used by other tools
This commit is contained in:
Peter Evans 2020-06-30 14:59:38 +09:00 committed by GitHub
commit 432cd004b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 38 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
- `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_PASSWORD` - Docker Hub 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_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. 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. 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.

View file

@ -1,9 +1,22 @@
name: 'Docker Hub Description'
author: 'Peter Evans'
description: 'An action to update a Docker Hub repository description from README.md'
# env:
# DOCKERHUB_USERNAME:
# description: Username to login to Docker Hub. Aliases: DOCKER_USERNAME
# required: true
# DOCKERHUB_PASSWORD:
# description: Password to login to Docker Hub. Aliases: DOCKER_PASSWORD
# required: true
# DOCKERHUB_REPOSITORY:
# description: Explicit Docker Hub repository name. Aliases: DOCKER_REPOSITORY, GITHUB_REPOSITORY
# required: true
# README_FILEPATH:
# description: Path to the repository readme.
# default: ./README.md
runs:
using: 'docker'
image: 'docker://peterevans/dockerhub-description:2.1.1'
branding:
icon: 'upload'
icon: 'upload'
color: 'blue'

View file

@ -1,7 +1,27 @@
#!/bin/sh -l
set -euo pipefail
set -eo pipefail
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
README_FILEPATH=${README_FILEPATH:="./README.md"}