Files
unity/unity-command/action.yaml

105 lines
3.4 KiB
YAML

name: unity-command
description: "Run a Unity command using a specified version of Unity."
inputs:
platform:
description: "Unity Platform. Options: windows, windows32bit, mac, linux, android"
required: true
version:
description: "Unity Version."
required: true
imageTag:
description: "Tag to use for the temporary version of Unity. Must refer to an existing public Docker image. Must be the same is in the Dockerfile of the called action."
required: true
default: unityci/base:latest
serial:
description: "Unity license serial number. Or 'public' for a public license."
required: true
default: public
email:
description: "Unity email."
required: true
password:
description: "Unity password."
required: true
command:
description: "Unity command to run."
required: false
noGraphics:
description: "Whether or not to use the graphics device when running Unity."
required: false
default: "true"
catchErrors:
description: "Whether or not errors should be handled."
required: false
sshPublicKey:
description: "Public SSH key to use for git package restoration."
required: false
sshPrivateKey:
description: "Private SSH key to use for git package restoration."
required: false
unityBuilder:
description: "Whether or not to use the UnityBuilder instead of a Unity command."
required: false
runs:
using: "composite"
steps:
- name: "Print Inputs"
run: |
NAME="Unity Command"
echo "::group::$NAME - Inputs"
echo "${{ toJSON(inputs) }}"
echo "::endgroup::"
shell: bash
- name: "Get Unity container name."
id: getContainer
uses: act/unity/unity-get-container@master
with:
version: ${{ inputs.version }}
platform: ${{ inputs.platform }}
- name: "Pull Unity container."
run: |
IMAGE_TAG="${{ inputs.imageTag }}"
CONTAINER="${{ steps.getContainer.outputs.container }}"
CACHED_CONTAINER="$CONTAINER-cached"
docker build -t "$CACHED_CONTAINER" --build-arg IMAGE="$CONTAINER" ${{ github.action_path }}
docker tag "$CACHED_CONTAINER" "$IMAGE_TAG"
shell: bash
- name: "Get Unity Command."
id: command
run: |
COMMAND="${{ inputs.command }}"
NO_GRAPHICS="${{ inputs.noGraphics }}"
if [[ "$NO_GRAPHICS" == "true" ]]; then
COMMAND="-nographics $COMMAND"
fi
echo "command=$COMMAND" >> "$GITHUB_OUTPUT"
LOCK_NAME="unity-lock:unity-lock"
echo "lockName=$LOCK_NAME" >> "$GITHUB_OUTPUT"
# Acquire Docker lock for exclusive access to retag the static image
bash ${{ github.action_path }}/acquire_lock.sh "$LOCK_NAME"
shell: bash
- name: "Run Unity command."
uses: act/unity/unity@master
env:
SSH_PUBLIC_KEY: ${{ inputs.sshPublicKey }}
SSH_PRIVATE_KEY: ${{ inputs.sshPrivateKey }}
CATCH_ERRORS: ${{ inputs.catchErrors }}
LOCK_NAME: ${{ steps.command.outputs.lockName }}
with:
serial: ${{ inputs.serial }}
# serial: "activated"
email: ${{ inputs.email }}
password: ${{ inputs.password }}
command: ${{ steps.command.outputs.command }}
unityBuilder: ${{ inputs.unityBuilder }}
- name: "Release Unity Docker lock."
if: ${{ always() }}
run: |
LOCK_NAME="${{ steps.command.outputs.lockName }}"
echo "Releasing Docker lock '$LOCK_NAME'..."
docker rmi "$LOCK_NAME" >/dev/null 2>&1 || true
shell: bash