Updated checkout.

This commit is contained in:
2025-06-27 12:25:18 -07:00
parent 6056b61b57
commit 1efb518fdf
17 changed files with 1 additions and 666 deletions

View File

@@ -1,22 +0,0 @@
#Arg is replaced with the desired Unity container.
ARG IMAGE=unityci/base:latest
FROM ${IMAGE}
RUN apt update
RUN apt install -y wget chromium-browser
#ADD https://minio.studiowhy.net/hackmd/UnityBuilder /usr/local/bin/
COPY UnityBuilder /usr/local/bin/
RUN chmod +x /usr/local/bin/UnityBuilder
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
COPY scripts/. /scripts
# Commented out until better image selection is enabled.
# RUN --mount=type=secret,id=SERIAL \
# --mount=type=secret,id=USERNAME \
# --mount=type=secret,id=PASSWORD \
# bash /scripts/activate_license.sh
ENTRYPOINT ["/entrypoint.sh"]

Binary file not shown.

View File

@@ -1,84 +0,0 @@
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"
unityBuilder:
description: "Whether or not to use the UnityBuilder instead of a Unity command."
required: false
removeContainer:
description: "Remove the mock container after building."
required: false
default: "true"
runs:
using: "composite"
steps:
- 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: |
CONTAINER="${{ steps.getContainer.outputs.container }}"
CACHED_CONTAINER="$CONTAINER-activated"
# Activate the license on build.
# DOCKER_BUILDKIT=1 \
# SERIAL="${{ inputs.serial }}" USERNAME="${{ inputs.email }}" PASSWORD="${{ inputs.password }}" \
# docker build --secret id=SERIAL,env=SERIAL --secret id=USERNAME,env=USERNAME --secret id=PASSWORD,env=PASSWORD \
# -t $CACHED_CONTAINER --build-arg IMAGE=$CONTAINER ${{ github.action_path }}
docker build -t $CACHED_CONTAINER --build-arg IMAGE=$CONTAINER ${{ github.action_path }}
docker tag $CACHED_CONTAINER ${{ inputs.imageTag }}
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"
- name: "Run Unity command."
uses: act/unity/unity@master
with:
serial: ${{ inputs.serial }}
# serial: "activated"
email: ${{ inputs.email }}
password: ${{ inputs.password }}
command: ${{ steps.command.outputs.command }}
unityBuilder: ${{ inputs.unityBuilder }}
- name: "Remove temporary image."
if: ${{ inputs.removeContainer == 'true' }}
run: |
docker image rm ${{ inputs.imageTag }}
shell: bash

View File

@@ -1,24 +0,0 @@
#!/bin/bash
SERIAL=$1; EMAIL=$2; PASSWORD=$3; COMMAND=$4; UNITY_BUILDER=$5
DEFAULT_ARGS="-quit -logFile -"
rm -rf $HOME/.config/unity3d
rm -rf /home/unity/.config/unity3d
#Add ssh key information for resolving packages.
bash /scripts/add_ssh_keys.sh
if [[ "$SERIAL" != "activated" ]]; then
echo "::group::Activating Unity License"
bash /scripts/activate_license.sh "$SERIAL" "$EMAIL" "$PASSWORD"
echo "::endgroup::"
fi
echo "::group::Running Unity Command"
#Run the command.
if [[ -n "$UNITY_BUILDER" ]]; then
UnityBuilder $COMMAND
else
unity-editor $DEFAULT_ARGS $COMMAND
fi
echo "::endgroup::"

View File

@@ -1,29 +0,0 @@
#!/bin/bash
SERIAL=$1; USERNAME=$2; PASSWORD=$3;
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 $USERNAME -p $PASSWORD
else
unity-editor $DEFAULT_ARGS -serial $SERIAL -username $USERNAME -password $PASSWORD
fi

View File

@@ -1,17 +0,0 @@
#!/bin/bash
if [[ -n "$SSH_PUBLIC_KEY" && -n "$SSH_PRIVATE_KEY" ]]; then
echo "ADDING SSH KEYS!"
SSH_DIR="/home/$(whoami)/.ssh"
mkdir -p $SSH_DIR
echo "$SSH_PUBLIC_KEY" > $SSH_DIR/id_rsa.pub
echo "$SSH_PRIVATE_KEY" > $SSH_DIR/id_rsa
cat << EOF > $SSH_DIR/config
Host *
StrictHostKeyChecking no
EOF
chmod 600 $SSH_DIR/id_rsa
chmod 644 $SSH_DIR/id_rsa.pub
cat $SSH_DIR/config
fi

View File

@@ -1,77 +0,0 @@
name: unity-composite
description: "Run a Unity command using a project's version and a build target. Then compress the result to a zip file."
inputs:
platform:
description: "Unity Platform. Options: windows, windows32bit, mac, linux, android"
required: true
email:
description: "Unity email."
required: true
password:
description: "Unity password."
required: true
command:
description: "Unity command to run."
required: false
unityBuilder:
description: "Whether or not to use the UnityBuilder instead of a Unity command."
required: false
buildDir:
description: "Where the built application ends up."
required: false
default: build
cacheVolume:
description: "Name of the volume to cache the Library folder to."
required: false
artifactsVolume:
description: "Name of the volume to copy the artifacts to."
required: true
artifactsDir:
description: "Name of the directory to copy the artifacts from."
required: true
default: artifacts
noGraphics:
description: "Whether or not to use the graphics device when running Unity."
required: false
default: "true"
zipName:
description: "Name of the resulting zip file."
required: false
artifactMode:
description: "The mode with which to publish artifacts. Options: copy, own, or null Default: copy"
required: false
default: ""
runs:
using: "composite"
steps:
- name: "Checkout"
uses: actions/checkout@v2
- uses: act/unity/unity-project@master
with:
platform: ${{ inputs.platform }}
email: ${{ inputs.email }}
password: ${{ inputs.password }}
command: ${{ inputs.command }}
unityBuilder: ${{ inputs.unityBuilder }}
cacheVolume: ${{ inputs.cacheVolume }}
noGraphics: ${{ inputs.noGraphics }}
- name: "Compress build"
if: ${{ inputs.zipName }}
env:
WORKDIR: ${{ inputs.buildDir }}
uses: act/common/utils/compress@master
with:
name: ../${{ inputs.artifactsDir }}/${{ inputs.zipName }}
files: .
- name: "Own artifacts"
if: inputs.artifactMode == 'own'
uses: act/common/utils/chown@master
with:
file: ${{ inputs.artifactsDir }}
- name: "Copy artifacts"
if: inputs.artifactMode == 'copy'
uses: act/common/docker/docker-cp@master
with:
recreateVolume: true
volume: ${{inputs.artifactsVolume }}
fromPath: ${{ inputs.artifactsDir }}/.

View File

@@ -1,58 +0,0 @@
name: unity-default
description: "Run a Unity command using defaults loaded from environment variables."
inputs:
platform:
description: "Unity Platform. Options: windows, windows32bit, mac, linux, android"
required: true
default: ${{ env.UNITY_PLATFORM }}
email:
description: "Unity email."
required: true
default: ${{ env.UNITY_USERNAME }}
password:
description: "Unity password."
required: true
default: ${{ env.UNITY_PASSWORD }}
command:
description: "Unity command to run."
required: false
unityBuilder:
description: "Whether or not to use the UnityBuilder instead of a Unity command."
required: false
buildDir:
description: "Where the built application ends up."
required: false
default: ${{ env.BUILD_DIR || 'build' }}
cacheVolume:
description: "Name of the volume to cache the Library folder to."
required: false
artifactsVolume:
description: "Name of the volume to copy the artifacts to."
required: true
default: ${{ env.ARTIFACTS_VOLUME }}
noGraphics:
description: "Whether or not to use the graphics device when running Unity."
required: false
default: ${{ env.NO_GRAPHICS || 'true' }}
artifactsDir:
description: "Name of the directory to copy the artifacts from."
required: true
default: artifacts
zipName:
description: "Name of the resulting zip file."
required: false
runs:
using: "composite"
steps:
- uses: act/unity/unity-composite@master
with:
platform: ${{ inputs.platform }}
email: ${{ inputs.email }}
password: ${{ inputs.password }}
command: ${{ inputs.command }}
unityBuilder: ${{ inputs.unityBuilder }}
buildDir: ${{ inputs.buildDir }}
artifactsDir: ${{ inputs.artifactsDir }}
cacheVolume: ${{ inputs.cacheVolume }}
zipName: ${{ inputs.zipName }}
noGraphics: ${{ inputs.noGraphics }}

View File

@@ -1,23 +0,0 @@
name: unity-get-buildtarget
description: "Get the correct Unity build target from a provided platform."
inputs:
platform:
description: "Unity Platform. Options: windows, windows32bit, mac, linux, android"
required: true
outputs:
buildTarget:
description: "Unity Build Target."
value: ${{ steps.getTarget.outputs.buildTarget }}
buildArg:
description: "Unity Build Argument."
value: ${{ steps.getTarget.outputs.buildArg }}
runs:
using: "composite"
steps:
- name: "Get Unity Build Target."
id: getTarget
run: |
#Choose the correct buildTarget: https://docs.unity3d.com/Manual/EditorCommandLineArguments.html
bash ${{ github.action_path }}/get_target.sh "${{ inputs.platform }}"
shell: bash

View File

@@ -1,38 +0,0 @@
#!/bin/bash
UNITY_TARGET="$1"
TARGET=$(echo "$UNITY_TARGET" | awk '{print tolower($0)}')
BUILD_ARG=""
case $TARGET in
"windows")
UNITY_TARGET=Win64
BUILD_ARG=-buildWindows64Player
;;
"windows32bit")
UNITY_TARGET=Win
BUILD_ARG=-buildWindowsPlayer
;;
"mac")
UNITY_TARGET=OSXUniversal
BUILD_ARG=-buildOSXUniversalPlayer
;;
"ios")
UNITY_TARGET=iOS
;;
"linux")
UNITY_TARGET=Linux64
BUILD_ARG=-buildLinux64Player
;;
"android")
UNITY_TARGET=Android
;;
"webgl")
UNITY_TARGET=WebGL
;;
*)
echo "Invalid target. Valid options are: Windows, Windows32bit, Mac, iOS, Linux, Android, WebGL"
;;
esac
echo "buildTarget=$UNITY_TARGET" >> "$GITHUB_OUTPUT"
echo "buildArg=$BUILD_ARG" >> "$GITHUB_OUTPUT"

View File

@@ -1,23 +0,0 @@
name: unity-get-container
description: "Get the correct Unity docker container from a provided platform."
inputs:
version:
description: "Unity Version."
required: true
platform:
description: "Unity Platform. Options: windows, windows32bit, mac, linux, android"
required: true
outputs:
container:
description: "Unity Docker Container"
value: ${{ steps.getContainer.outputs.container }}
runs:
using: "composite"
steps:
- name: "Get Unity Docker Container."
id: getContainer
run: |
#Choose the appropriate container from: https://hub.docker.com/r/unityci/editor
bash ${{ github.action_path }}/get_container.sh "${{ inputs.platform }}" "${{ inputs.version }}"
shell: bash

View File

@@ -1,37 +0,0 @@
#!/bin/bash
# Choose the appropriate container from: https://hub.docker.com/r/unityci/editor
UNITY_TARGET="$1"
UNITY_VERSION="$2"
TARGET=$(echo "$UNITY_TARGET" | awk '{print tolower($0)}')
BUILD_ARG=""
case $TARGET in
"windows" | "windows32bit")
UNITY_TARGET=windows-mono-1
;;
"mac" | "osx")
UNITY_TARGET=mac-mono-1
;;
"ios")
UNITY_TARGET=ios-1
UNITY_VERSION=ubuntu-$UNITY_VERSION
;;
"linux")
UNITY_TARGET=base-1
UNITY_VERSION=ubuntu-$UNITY_VERSION
;;
"android")
UNITY_TARGET=android-1
UNITY_VERSION=ubuntu-$UNITY_VERSION
;;
"webgl")
UNITY_TARGET=webgl-1
UNITY_VERSION=ubuntu-$UNITY_VERSION
;;
*)
echo "Invalid target. Valid options are: Windows, Windows32bit, Mac, iOS, Linux, Android, WebGL"
;;
esac
CONTAINER=unityci/editor:$UNITY_VERSION-$UNITY_TARGET
echo "container=$CONTAINER" >> "$GITHUB_OUTPUT"

View File

@@ -1,25 +0,0 @@
name: unity-get-version
description: "Get the correct Unity version from a provided project."
inputs:
projectPath:
description: "Path to the Unity project."
required: true
default: "."
outputs:
projectVersion:
description: "Unity project version."
value: ${{ steps.getVersion.outputs.projectVersion }}
runs:
using: "composite"
steps:
- name: "Get Unity project version."
id: getVersion
run: |
VERSION_KEY="m_EditorVersion"
VERSION_FILE="ProjectSettings/ProjectVersion.txt"
VERSION_FILE_PATH="${{ inputs.projectPath }}/$VERSION_FILE"
VERSION=$(grep -w $VERSION_KEY $VERSION_FILE_PATH | cut -d ':' -f2 | xargs)
echo "projectVersion=$VERSION" >> "$GITHUB_OUTPUT"
shell: bash

View File

@@ -1,105 +0,0 @@
name: unity-project-cached
description: "Run a Unity command using a project's version and a build target. Cache the library folder."
inputs:
projectPath:
description: "Path to the Unity project."
required: true
default: "."
platform:
description: "Unity Platform. Options: windows, windows32bit, mac, linux, android"
required: true
serial:
description: "Unity license serial number."
required: true
email:
description: "Unity email."
required: true
password:
description: "Unity password."
required: true
executeMethod:
description: "Unity method to call."
required: false
command:
description: "Additional unity commands."
required: false
buildOnCacheHit:
description: "Whether or not to build if a cache was found. Default: true"
required: false
default: "true"
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
cacheSuffix:
description: "Suffix or hash to use for the cache key."
required: false
default: ${{ github.sha }}
cachePrefix:
description: "Prefix to use for the cache key."
required: false
default: unity-library
releaseBranch:
description: "Release name to use for the middle of the cache key if an exact release match was not found."
required: false
default: release
cachePath:
description: "Cache path. Default: Library"
required: false
default: Library
outputs:
cacheChanged:
description: "Whether or not the cache was changed."
value: ${{ steps.check-cache.outputs.cache-hit != 'true' }}
runs:
using: "composite"
steps:
- name: "Get full cache key and build command."
id: command
run: |
# Get the full cache id.
echo "key=${{ inputs.cachePrefix }}-${{ github.ref_name }}-${{ inputs.cacheSuffix }}" >> "$GITHUB_OUTPUT"
# Get the build command.
COMMAND="${{ inputs.command }}"
if [[ -n "${{ inputs.executeMethod }}" ]]; then
COMMAND="$COMMAND -executeMethod ${{ inputs.executeMethod }}"
fi
echo "command=$COMMAND" >> "$GITHUB_OUTPUT"
shell: bash
- name: "Check if cache exists."
if: ${{ !env.ACT }}
id: check-cache
uses: actions/cache/restore@v3
with:
path: ${{ inputs.cachePath }}
key: ${{ steps.command.outputs.key }}
lookup-only: true
- name: "Restore Library from Cache."
if: ${{ !env.ACT && ( inputs.buildOnCacheHit == 'true' || steps.check-cache.outputs.cache-hit != 'true' ) }}
uses: actions/cache/restore@v3
with:
path: ${{ inputs.cachePath }}
key: ${{ steps.command.outputs.key }}
restore-keys: |
${{ inputs.cachePrefix }}-${{ github.ref_name }}
${{ inputs.cachePrefix }}-${{ inputs.releaseBranch }}
${{ inputs.cachePrefix }}
- name: "Build project."
if: ${{ inputs.buildOnCacheHit == 'true' || steps.check-cache.outputs.cache-hit != 'true' }}
uses: act/common/unity/unity-project@master
with:
platform: ${{ inputs.platform }}
serial: ${{ inputs.serial }}
email: ${{ inputs.email }}
password: ${{ inputs.password }}
sshPublicKey: ${{ inputs.sshPublicKey }}
sshPrivateKey: ${{ inputs.sshPrivateKey }}
command: ${{ steps.command.outputs.command }}
- name: "Upload Library to Cache."
if: ${{ !env.ACT && steps.check-cache.outputs.cache-hit != 'true' }}
uses: actions/cache/save@v3
with:
path: ${{ inputs.cachePath }}
key: ${{ steps.command.outputs.key }}

View File

@@ -1,74 +0,0 @@
name: unity-project
description: "Run a Unity command using a project's version and a build target."
inputs:
projectPath:
description: "Path to the Unity project."
required: true
default: "."
platform:
description: "Unity Platform. Options: windows, windows32bit, mac, linux, android"
required: true
serial:
description: "Unity license serial number. Or 'personal' for a personal license."
required: true
default: personal
email:
description: "Unity email."
required: true
password:
description: "Unity password."
required: true
command:
description: "Unity command to run."
required: false
unityBuilder:
description: "Whether or not to use the UnityBuilder instead of a Unity command."
required: false
noGraphics:
description: "Whether or not to use the graphics device when running Unity."
required: false
default: "true"
cacheVolume:
description: "Name of the volume to cache the Library folder to."
required: false
removeContainer:
description: "Remove the mock container after building."
required: false
default: "false"
runs:
using: "composite"
steps:
- name: "Get Unity Version."
id: getVersion
uses: act/unity/unity-get-version@master
with:
projectPath: ${{ inputs.projectPath }}
- name: "Get Unity buildTarget."
id: getTarget
uses: act/unity/unity-get-buildtarget@master
with:
platform: ${{ inputs.platform }}
- name: "Restore the cached Library folder."
if: inputs.cacheVolume != null
uses: act/common/docker/docker-cp@master
with:
volume: ${{ inputs.cacheVolume }}
toPath: .
- name: "Run Unity command."
uses: act/unity/unity-command@master
with:
platform: ${{ inputs.platform }}
version: ${{ steps.getVersion.outputs.projectVersion }}
serial: ${{ inputs.serial }}
email: ${{ inputs.email }}
password: ${{ inputs.password }}
command: -projectPath ${{ inputs.projectPath }} -buildTarget ${{ steps.getTarget.outputs.buildTarget }} ${{ inputs.command }}
removeContainer: ${{ inputs.removeContainer }}
noGraphics: ${{ inputs.noGraphics }}
- name: "Cache the Library folder."
if: inputs.cacheVolume != null
uses: act/common/docker/docker-cp@master
with:
recreateVolume: true
volume: ${{ inputs.cacheVolume }}
fromPath: Library

View File

@@ -1,29 +0,0 @@
name: unity
description: "Register Unity with the provided license and run a Unity command."
inputs:
serial:
description: "Unity license serial number. Or 'personal' for a personal license. Or 'activated' to skip activation."
required: true
default: personal
email:
description: "Unity email."
required: true
password:
description: "Unity password."
required: true
command:
description: "Unity command to run."
required: false
unityBuilder:
description: "Whether or not to use the UnityBuilder instead of a Unity command."
required: false
runs:
using: docker
#This is a base "mock" image which is replaced by the correct image in the "unity-command" action at runtime.
image: docker://unityci/base:latest
args:
- ${{ inputs.serial }}
- ${{ inputs.email }}
- ${{ inputs.password }}
- ${{ inputs.command }}
- ${{ inputs.unityBuilder }}

View File

@@ -5,7 +5,7 @@ jobs:
run-tests: run-tests:
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
steps: steps:
- uses: actions/checkout@v3 - uses: https://github.com/actions/checkout@v3
- name: "Run Test" - name: "Run Test"
id: test id: test
uses: ./. uses: ./.