Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
password: ${{ secrets.DOCKER_PASSWORD }}
registry: gcr.io
image: private-image:latest
options: -v ${{ github.workspace }}:/work -e ABC=123
volumes: ${{ github.workspace }}:/work,/other/path:/other/path # comma separated list
options: -e ABC=123
run: |
echo "Running Script"
/work/run-script
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ inputs:
image:
description: 'Image'
required: true
volumes:
description: "Volume mounts"
required: false
options:
description: 'Options'
required: false
Expand Down
14 changes: 10 additions & 4 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
#!/usr/bin/env bash

if [ ! -z $INPUT_USERNAME ];
then echo $INPUT_PASSWORD | docker login $INPUT_REGISTRY -u $INPUT_USERNAME --password-stdin
if [ -n "$INPUT_USERNAME" ];
then echo "$INPUT_PASSWORD" | docker login "$INPUT_REGISTRY" -u "$INPUT_USERNAME" --password-stdin
fi

if [ ! -z $INPUT_DOCKER_NETWORK ];
if [ -n "$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'/;}"
if [ -n "$INPUT_VOLUMES" ];
then
VOLUMES=$(echo "$INPUT_VOLUMES" | sed -r 's/[ ]?,[ ]?/ -v /g')
INPUT_OPTIONS="$INPUT_OPTIONS -v $VOLUMES"
fi

exec docker run -v /var/run/docker.sock:/var/run/docker.sock "$INPUT_OPTIONS" --entrypoint="$INPUT_SHELL" "$INPUT_IMAGE" -c "${INPUT_RUN//$'\n'/;}"