cleaned things up

This commit is contained in:
Lachee 2025-05-07 14:07:07 +10:00
parent 278fefb6e0
commit f4125a73a8
6 changed files with 119 additions and 23 deletions

View File

@ -0,0 +1,49 @@
name: Create Images
on:
workflow_dispatch:
jobs:
get-versions:
runs-on: ubuntu-latest
outputs:
versions: ${{ steps.get-versions.outputs.versions }}
steps:
- name: Get Unity Versions
id: get-versions
run: |
VERSIONS=$(head -n -1 versions.txt | tr '\n' ',')
echo "::set-output name=versions::$VERSIONS"
build-docker:
needs: get-versions
runs-on: ubuntu-latest
env:
GAMECI_VERSION: 3
PLATFORM: linux/amd64
DOCKER_REGISTRY: docker.lakes.house
strategy:
matrix:
platform:
- webgl
- android
version: ${{ fromJson(needs.get-versions.outputs.versions) }}
steps:
- uses: actions/checkout@v4
- name: Login to Docker Registry
uses: docker/login-action@v3
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build Docker Image
run: ./scripts/build-image.sh
env:
UNITY_VERSION: ${{ matrix.version }}
UNITY_PLATFORM: ${{ matrix.platform }}
GAMECI_VERSION: ${{ env.GAMECI_VERSION }}
- name: Push Docker Image
if: ${{ false }}

View File

@ -5,6 +5,8 @@ on:
push: push:
branches: branches:
- main - main
paths:
- 'versions.txt'
jobs: jobs:
build-docker: build-docker:
@ -19,8 +21,7 @@ jobs:
platform: platform:
- webgl - webgl
- android - android
version:
- 6000.0.35f1
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Login to Docker Registry - name: Login to Docker Registry
@ -30,19 +31,18 @@ jobs:
username: ${{ secrets.DOCKER_USERNAME }} username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }} password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build Docker Image - name: Get Unity Version
id: get-unity-version
run: | run: |
BASE_IMAGE=unityci/editor:ubuntu-${UNITY_VERSION}-${UNITY_PLATFORM}-${GAME_CI_VERSION} VERSION=$(head -n 1 versions.txt)
TAG=${{ env.DOCKER_REGISTRY }}/unityci/editor:ubuntu-${UNITY_VERSION}-${UNITY_PLATFORM}-runner echo "UNITY_VERSION=$VERSION" >> $GITHUB_ENV
docker build \
--platform ${PLATFORM} \
--build-arg GAME_CI_UNITY_EDITOR_IMAGE=${BASE_IMAGE} \
-t ${TAG} \
Dockerfiles/UnityEditor.Dockerfile
- name: Build Docker Image
run: ./scripts/build-image.sh
env: env:
UNITY_VERSION: ${{ matrix.version }} UNITY_VERSION: ${{ env.UNITY_VERSION }}
UNITY_PLATFORM: ${{ matrix.platform }} UNITY_PLATFORM: ${{ matrix.platform }}
GAMECI_VERSION: ${{ env.GAMECI_VERSION }}
- name: Push Docker Image
if: ${{ false }}

View File

@ -1,6 +1,6 @@
ARG GAME_CI_UNITY_EDITOR_IMAGE=unityci/editor ARG BASE_IMAGE=unityci/editor
FROM $GAME_CI_UNITY_EDITOR_IMAGE FROM $BASE_IMAGE
# Setup Dependants # Setup Dependants
RUN apt-get update && \ RUN apt-get update && \

View File

@ -1,6 +0,0 @@
images:
versions:
- 6000.0.35f1
modules:
- android
- webgl

51
scripts/build-image.sh Normal file
View File

@ -0,0 +1,51 @@
#!/bin/sh
# Ensure UNITY_VERSION is set, pull from arguments if not
if [ -z "${UNITY_VERSION}" ]; then
if [ -n "$1" ]; then
UNITY_VERSION=$1
else
echo "Error: UNITY_VERSION is not set."
exit 1
fi
fi
# Ensure UNITY_PLATFORM is set, pull from arguments if not
if [ -z "${UNITY_PLATFORM}" ]; then
if [ -n "$2" ]; then
UNITY_PLATFORM=$2
else
echo "Error: UNITY_PLATFORM is not set."
exit 1
fi
fi
# Ensure GAME_CI_VERSION is set, default to 3 if not
if [ -z "${GAMECI_VERSION}" ]; then
GAMECI_VERSION=3
fi
BASE_IMAGE=unityci/editor:ubuntu-${UNITY_VERSION}-${UNITY_PLATFORM}-${GAMECI_VERSION}
TAG=ubuntu-${UNITY_VERSION}-${UNITY_PLATFORM}-runner
echo "Base Image: ${BASE_IMAGE}"
echo "Tag: ${TAG}"
echo "Image: ${IMAGE_NAME}:${TAG}"
docker build \
--platform ${PLATFORM} \
--build-arg BASE_IMAGE=${BASE_IMAGE} \
-t ${IMAGE_NAME}:${TAG} \
${DOCKER_BUILD_ARGS} \
Dockerfiles/Runner.Dockerfile
if [ $? -ne 0 ]; then
echo "Error: Docker build failed."
exit 1
fi
# Export IMAGE_NAME and TAG for GitHub Actions
if [ -n "$GITHUB_ENV" ]; then
echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV
echo "TAG=${TAG}" >> $GITHUB_ENV
fi
``

2
versions.txt Normal file
View File

@ -0,0 +1,2 @@
6000.0.35f1
-- list of versions with the latest being on top