updated to unity v6 #40
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: Deploy Unity WebGL to GitHub Pages | |
| on: | |
| push: | |
| branches: ["main"] | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| name: Build Unity Project | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Cache Library folder | |
| uses: actions/cache@v3 | |
| with: | |
| path: Library | |
| key: Library-WebGL | |
| restore-keys: | | |
| Library- | |
| - name: Unity - Builder | |
| uses: game-ci/unity-builder@v4 | |
| env: | |
| UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} | |
| UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} | |
| UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} | |
| with: | |
| targetPlatform: WebGL | |
| buildsPath: build | |
| - name: List build directory | |
| run: ls -R build/ | |
| - name: Upload Build Artifact | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: WebGL-Build | |
| path: build/WebGL | |
| deploy: | |
| name: Deploy to GitHub Pages | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Check and create gh-pages branch | |
| run: | | |
| if ! git ls-remote --exit-code --heads origin gh-pages; then | |
| git checkout --orphan gh-pages | |
| git rm -rf . | |
| touch .nojekyll | |
| git add .nojekyll | |
| git config --global user.name 'github-actions[bot]' | |
| git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
| git commit -m "Initial gh-pages commit" | |
| git push origin gh-pages | |
| fi | |
| - name: Checkout gh-pages branch | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: gh-pages | |
| clean: true | |
| - name: Download Build Artifact | |
| uses: actions/download-artifact@v3 | |
| with: | |
| name: WebGL-Build | |
| path: . | |
| - name: List downloaded files | |
| run: | | |
| echo "Current directory contents:" | |
| ls -la | |
| echo "WebGL directory contents (if exists):" | |
| ls -la WebGL || echo "WebGL directory not found" | |
| - name: Move files to root | |
| run: | | |
| if [ -d "WebGL" ]; then | |
| cp -r WebGL/* . | |
| rm -rf WebGL | |
| fi | |
| - name: Ensure .nojekyll exists | |
| run: touch .nojekyll | |
| - name: Commit and Push to gh-pages | |
| run: | | |
| git config --global user.name 'github-actions[bot]' | |
| git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
| git add -A | |
| git commit -m "Deploy Unity WebGL build to GitHub Pages" || echo "No changes to commit" | |
| git push origin gh-pages |