diff --git a/README.md b/README.md index eab5a93..a56f2cf 100644 --- a/README.md +++ b/README.md @@ -12,12 +12,14 @@ - name: Checkout uses: actions/checkout@v2 # Required to mount the Github Workspace to a volume - uses: addnab/docker-run-action@v3 + env: + ABC: 123 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} registry: gcr.io image: private-image:latest - options: -v ${{ github.workspace }}:/work -e ABC=123 + options: -v ${{ github.workspace }}:/work run: | echo "Running Script" /work/run-script diff --git a/entrypoint.sh b/entrypoint.sh index 39c1d70..cc8e887 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +env | egrep -v "^(#|;| |INPUT_*|PATH|HOME)" | awk '$1 ~ /^\w+=/' | xargs -0 > docker-run-action.env + if [ ! -z $INPUT_USERNAME ]; then echo $INPUT_PASSWORD | docker login $INPUT_REGISTRY -u $INPUT_USERNAME --password-stdin fi @@ -8,4 +10,4 @@ if [ ! -z $INPUT_DOCKER_NETWORK ]; then INPUT_OPTIONS="$INPUT_OPTIONS --network $INPUT_DOCKER_NETWORK" fi -exec docker run -v "/var/run/docker.sock":"/var/run/docker.sock" $INPUT_OPTIONS --entrypoint=$INPUT_SHELL $INPUT_IMAGE -c "${INPUT_RUN//$'\n'/;}" +exec docker run --env-file docker-run-action.env -v "/var/run/docker.sock":"/var/run/docker.sock" $INPUT_OPTIONS --entrypoint=$INPUT_SHELL $INPUT_IMAGE -c "${INPUT_RUN//$'\n'/;}"