Skip to content

fix unity build

fix unity build #172

Workflow file for this run

name: Unity WebGL Automatic Build 👽✨🚀
on:
push:
branches:
- '1-configure-as-a-unity-package'
pull_request:
branches:
- 'main'
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
build:
name: Unity Build 👽
runs-on: ubuntu-latest
steps:
# Step 1: Checkout repository without LFS
- name: Checkout repository
uses: actions/checkout@v2
with:
token: ${{ secrets.PAT }}
# Step 2: Git LFS: Restore LFS files
- name: Create LFS file list
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
- name: Restore LFS cache
uses: actions/cache@v2
id: lfs-cache
with:
path: .git/lfs
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}
- name: Git LFS Pull
run: |
git lfs pull
git add .
git reset --hard
# Step 3: Cache Unity Library
- uses: actions/cache@v2
with:
path: Library
key: Library-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
restore-keys: |
Library-
# Step 4: Build Unity Project
- name: Build project
run: |
docker rmi $(docker images -q)
docker pull unityci/editor:ubuntu-2022.3.10f1-webgl-3.1.0
docker run --rm \
-v $GITHUB_WORKSPACE:/workspace \
-e UNITY_LICENSE=$UNITY_LICENSE \
-e UNITY_EMAIL=$UNITY_EMAIL \
-e UNITY_PASSWORD=$UNITY_PASSWORD \
-e UNITY_SERIAL=$UNITY_SERIAL \
-e UNITY_VERSION=2022.3.10f1 \
-e BUILD_PATH=$BUILD_PATH \
-e BUILD_NAME=WebGL \
-e BUILD_TARGET=WebGL \
unityci/editor:ubuntu-2022.3.10f1-webgl-3.1.0 /bin/bash -c "/workspace/entrypoint.sh"
# Step 5: Upload Build Artifact
- name: Upload Build Artifact
uses: actions/upload-artifact@v3
with:
name: ${{ vars.ARTIFACT_NAME }}
path: ${{ vars.BUILD_PATH }}
# Step 6: Stash the build result and reset local changes
- name: Stash build result and reset local changes
run: |
echo "Stashing build result and resetting local changes"
sudo chown -R $USER:$USER ${{ vars.BUILD_PATH }}
git config --global user.email "${{ secrets.GH_EMAIL }}"
git config --global user.name "${{ secrets.GH_USERNAME }}"
git add ${{ vars.BUILD_PATH }}/${{ vars.TARGET_PLATFORM }}
git stash push ${{ vars.BUILD_PATH }}/${{ vars.TARGET_PLATFORM }}
git reset --hard
sudo git clean -d -x -f
# Step 7: Checkout gh-pages branch
- name: Checkout gh-pages branch
run: |
echo "Switching to gh-pages branch"
git switch -f ${{ secrets.DEPLOYMENT_BRANCH }}
git reset --hard
sudo git clean -d -x -f
# Step 8: Apply stashed changes to gh-pages branch
- name: Apply stashed changes to gh-pages
run: |
echo "Applying stashed changes to gh-pages"
git stash apply stash@{0}
git add *
git commit -m "Deploying latest build to gh-pages"
# Step 9: Push changes to gh-pages branch
- name: Push changes to gh-pages branch
run: |
echo "Pushing changes to gh-pages branch"
git push origin ${{ secrets.DEPLOYMENT_BRANCH }}
# Step 10: Clean up: Delete stashed changes (if any)
- name: Clean up stashed changes
run: |
echo "Cleaning up stashed changes"
git stash clear