diff --git a/unity-command/Dockerfile b/unity-command/Dockerfile index 8b999d4..679884f 100644 --- a/unity-command/Dockerfile +++ b/unity-command/Dockerfile @@ -2,10 +2,6 @@ ARG IMAGE=unityci/base:latest FROM ${IMAGE} -ARG SERIAL -ARG USERNAME -ARG PASSWORD - RUN apt update RUN apt install -y wget chromium-browser @@ -16,6 +12,9 @@ COPY entrypoint.sh / RUN chmod +x /entrypoint.sh COPY scripts/. /scripts -RUN bash /scripts/activate_license.sh ${SERIAL} ${USERNAME} ${PASSWORD} +RUN --mount=type=secret,id=SERIAL \ + --mount=type=secret,id=USERNAME \ + --mount=type=secret,id=PASSWORD \ + bash /scripts/activate_license.sh ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/unity-command/action.yaml b/unity-command/action.yaml index 05042a3..14cd90d 100644 --- a/unity-command/action.yaml +++ b/unity-command/action.yaml @@ -44,14 +44,17 @@ runs: run: | CONTAINER=${{ steps.getContainer.outputs.container }} - docker build -t ${{ inputs.imageTag }} --build-arg IMAGE=$CONTAINER ${{ github.action_path }} + SERIAL="${{ inputs.serial }}" USERNAME="${{ inputs.email }}" PASSWORD="${{ inputs.password }}" \ + # Activate the license on build. + docker build . --secret id=SERIAL,env=SERIAL --secret id=USERNAME,env=USERNAME --secret id=PASSWORD,env=PASSWORD \ + -t ${{ inputs.imageTag }} --build-arg IMAGE=$CONTAINER ${{ github.action_path }} shell: bash - name: "Run Unity command." uses: act/unity/unity@master with: - serial: ${{ inputs.serial }} - email: ${{ inputs.email }} - password: ${{ inputs.password }} + # serial: ${{ inputs.serial }} + # email: ${{ inputs.email }} + # password: ${{ inputs.password }} command: ${{ inputs.command }} unityBuilder: ${{ inputs.unityBuilder }} - name: "Remove temporary image." diff --git a/unity-command/scripts/activate_license.sh b/unity-command/scripts/activate_license.sh index 16589d2..81100fe 100644 --- a/unity-command/scripts/activate_license.sh +++ b/unity-command/scripts/activate_license.sh @@ -1,13 +1,29 @@ #!/bin/bash -SERIAL=$1; EMAIL=$2; PASSWORD=$3; +SERIAL=$1; USERNAME=$2; PASSWORD=$3; -if [[ -z "$SERIAL" || -z "$EMAIL" || -z "$PASSWORD" ]]; then +function check_path +{ + local SECRET_PATH="/run/secrets" + local ENV_NAME="$1" + local ENV_VALUE="${!ENV_NAME}" + + local FILE_PATH="$SECRET_PATH/$ENV_NAME" + if [[ -z "$ENV_VALUE" && -f "$FILE_PATH" ]]; then + export $ENV_NAME=$(cat "$FILE_PATH") + fi +} + +check_path SERIAL +check_path USERNAME +check_path PASSWORD + +if [[ -z "$SERIAL" || -z "$USERNAME" || -z "$PASSWORD" ]]; then exit 0 fi #Activate Unity if [[ "$SERIAL" == "personal" ]]; then - UnityBuilder activate -i /usr/bin/unity-editor -u $EMAIL -p $PASSWORD + UnityBuilder activate -i /usr/bin/unity-editor -u $USERNAME -p $PASSWORD else - unity-editor $DEFAULT_ARGS -serial $SERIAL -username $EMAIL -password $PASSWORD + unity-editor $DEFAULT_ARGS -serial $SERIAL -username $USERNAME -password $PASSWORD fi \ No newline at end of file