Skip to content

fix 2

fix 2 #166

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:
# Checkout Repository Job
checkout:
name: Checkout Repository
runs-on: ubuntu-22.04 # Ensure Ubuntu version is consistent
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
token: ${{ secrets.PAT }}
- name: Echo Checkout Completed
run: echo "Repository has been successfully checked out."
# Create Temporary Branch and Sync with Main Job
sync-main:
name: Sync Temp Branch with Main
runs-on: ubuntu-22.04
needs: checkout # This job depends on the "checkout" job
steps:
- name: Checkout deployment branch
run: |
echo "Checking out deployment branch: ${{ secrets.DEPLOYMENT_BRANCH }}"
git checkout ${{ secrets.DEPLOYMENT_BRANCH }}
- name: Create temporary branch
run: |
echo "Creating temporary branch from ${{ secrets.DEPLOYMENT_BRANCH }}"
git checkout -b temp
- name: Pull latest changes from main
run: |
echo "Pulling latest changes from main"
git pull origin main
- name: Echo Sync Main Completed
run: echo "Temporary branch has been successfully synced with main."
# Build Unity Project Job
build:
name: Build Unity Project
runs-on: ubuntu-22.04
needs: sync-main # This job depends on the "sync-main" job
steps:
- name: Pull Unity Image and Build Project
run: |
echo "Starting Unity build"
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"
- name: Echo Build Completed
run: echo "Unity build has completed successfully."
# Deploy to GitHub Pages Job
deploy:
name: Deploy to GitHub Pages and Upload Artifact
runs-on: ubuntu-22.04
needs: build # This job depends on the "build" job
steps:
- name: Checkout Deployment Branch
run: |
echo "Checking out deployment branch: ${{ secrets.DEPLOYMENT_BRANCH }}"
git checkout ${{ secrets.DEPLOYMENT_BRANCH }}
- name: Merge Temp Branch to Deployment Branch
run: |
echo "Merging changes from temp to deployment branch"
git merge temp --no-ff --commit -m "Merge build changes into deployment branch"
- name: Push Changes to Deployment Branch
run: |
echo "Pushing changes to deployment branch"
git push origin ${{ secrets.DEPLOYMENT_BRANCH }}
- name: Upload Build Artifact
uses: actions/upload-artifact@v3
with:
name: build-artifact
path: ${{ secrets.BUILD_PATH }}
- name: Deploy to GitHub Pages
run: |
echo "Deploying to GitHub Pages"
# Any deployment script or commands you need for GitHub Pages here.
- name: Echo Deployment Completed
run: echo "Deployment to GitHub Pages has been successfully completed."
# Clean Temporary Branch Job
cleanup:
name: Clean Up Temporary Branch
runs-on: ubuntu-22.04
needs: deploy # This job depends on the "deploy" job
steps:
- name: Delete Temporary Branch
run: |
echo "Deleting temporary branch"
git branch -D temp
- name: Push Cleanup
run: |
echo "Cleaning up remote branches"
git push origin --delete temp
- name: Echo Cleanup Completed
run: echo "Temporary branch has been deleted."