This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Unity WebGL Automatic Build 👽✨🚀 | |
| on: | |
| push: | |
| branches: | |
| - '1-configure-as-a-unity-package' | |
| pull_request: | |
| branches: | |
| - 'main' | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| name: Unity Build 👽 | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 1. Checkout repository | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| # 2. Set up Git LFS | |
| - name: Set up Git LFS | |
| run: | | |
| git lfs install | |
| git lfs pull | |
| # 3. Cache Unity Library | |
| - uses: actions/cache@v3 | |
| with: | |
| path: Library | |
| key: Library-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }} | |
| restore-keys: | | |
| Library- | |
| # 4. Build project using Unity Docker | |
| - name: Build WebGL with Unity | |
| run: | | |
| docker pull unityci/editor:ubuntu-2022.3.10f1-webgl-3.1.0 | |
| docker run --rm \ | |
| -v ${{ github.workspace }}:/workspace \ | |
| -e UNITY_LICENSE=$UNITY_LICENSE \ | |
| unityci/editor:ubuntu-2022.3.10f1-webgl-3.1.0 \ | |
| /bin/bash -c "/opt/unity/Editor/Unity -batchmode -nographics -quit -buildTarget WebGL -projectPath /workspace -executeMethod BuildPipeline.BuildPlayer" | |
| env: | |
| UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} | |
| # 5. Upload build artifact | |
| - name: Upload WebGL Build | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: WebGL-Build | |
| path: Build/WebGL/ | |
| # 6. Deploy to GitHub Pages | |
| - name: Deploy to GitHub Pages | |
| uses: peaceiris/actions-gh-pages@v3 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: Build/WebGL/ | |
| publish_branch: gh-pages |