starter-docker-github-actions/entrypoint.sh

34 lines
905 B
Bash
Raw Normal View History

#!/bin/bash
2021-07-14 17:15:43 +07:00
#### Current working directory is: /github/workspace ####
WORKDIR=$(pwd)
2021-07-14 17:21:39 +07:00
echo "Workdir => ${WORKDIR}"
2021-07-14 17:23:00 +07:00
ls $WORKDIR
if [ ! -z $INPUT_USERNAME ];
then echo $INPUT_PASSWORD | docker login $INPUT_REGISTRY -u $INPUT_USERNAME --password-stdin
fi
echo "$INPUT_RUN" | sed -e 's/\\n/;/g' > semicolon_delimited_script
if [ ! -z $INPUT_DOCKER_NETWORK ];
then INPUT_OPTIONS="$INPUT_OPTIONS --network $INPUT_DOCKER_NETWORK"
fi
2021-03-26 21:26:00 +07:00
if [ -z $INPUT_SHELL ];
2021-03-26 21:45:10 +07:00
then INPUT_SHELL=sh
2021-03-26 21:26:00 +07:00
fi
if [ -z $INPUT_IMAGE ];
2021-07-14 17:10:48 +07:00
then INPUT_IMAGE=cubetiq/calpine-docker
fi
2021-03-26 21:26:00 +07:00
if [ -z $semicolon_delimited_script ];
then semicolon_delimited_script="echo $(whoami)"
fi
2021-07-14 17:32:39 +07:00
echo "My name is: $(whoami)"
echo "Start executing docker..."
2021-07-14 17:40:04 +07:00
exec docker run --workdir "$WORKDIR" -v "$WORKDIR":"$WORKDIR" -v "/var/run/docker.sock":"/var/run/docker.sock" $INPUT_OPTIONS --entrypoint=$INPUT_SHELL $INPUT_IMAGE -c "`cat semicolon_delimited_script`"