Skip to content

Build and Deploy Unity Project to GitHub Pages #20

Build and Deploy Unity Project to GitHub Pages

Build and Deploy Unity Project to GitHub Pages #20

Workflow file for this run

name: Build and Deploy Unity Project to GitHub Pages
on:
push:
branches:
- main
workflow_dispatch:
permissions:
actions: write
checks: write
contents: read
pull-requests: read
statuses: write
pages: write
id-token: write
jobs:
test:
name: Unity Tests
runs-on: ubuntu-latest
steps:
# Checkout
- name: Checkout repository
uses: actions/checkout@v4
# Test
- name: Run tests
uses: game-ci/unity-test-runner@v4
with:
unityVersion: 2021.3.42f1
githubToken: ${{ secrets.GITHUB_TOKEN }}
env:
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
build:
needs: test
name: Build Unity Project
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Remove test code
run: rm -rf Assets/Scripts/Tests
rm Assets/Scripts/*.asmdef{,.meta}
- name: Copy Other Pages Files
run: |
mkdir -p build/WebGL/WebGL
cp -r Pages/* build/WebGL/WebGL/
- name: Build Unity Project
uses: game-ci/unity-builder@v4
with:
unityVersion: 2021.3.42f1
targetPlatform: WebGL
allowDirtyBuild: true
env:
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
- name: Upload Pages Artifact
uses: actions/upload-pages-artifact@v3
with:
path: build/WebGL/WebGL
# Deploy job
deploy:
needs: build
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4