TExcelTAD
Home › Assets, Tools & Shipping › GitHub Actions & GameCI

GitHub Actions & GameCI

Once the build runs from the command line (Command-Line Builds), a CI service can run it on every push: compile, run tests, build each platform, and keep the result as a downloadable artifact. This lesson uses GitHub Actions, because it's free for public repositories and widely used; GitLab CI, Jenkins, TeamCity, Buildkite and Unreal's Horde follow the same ideas. General CI concepts are in Git CI/CD and Docker CI/CD.

The shape of a workflow

A workflow is a YAML file in .github/workflows/. It has triggers (on:), jobs that run on fresh virtual machines (runs-on:), and steps that either run shell commands (run:) or use published actions (uses: owner/repo@version). Secrets (licence files, API keys) are stored in the repository settings and read as ${{ secrets.NAME }}; they are masked in logs.

Note: Action versions below were current when this lesson was written (GameCI documents unity-builder@v4; its current major, v6, keeps the same inputs). Check each action's releases page and pin a major version.

Unity with GameCI

GameCI provides open-source actions and Docker images with the Unity editor preinstalled. game-ci/unity-test-runner runs your edit-mode and play-mode tests; game-ci/unity-builder builds a target platform. Licensing comes from secrets: for a Personal licence UNITY_LICENSE (the contents of your activated .ulf file), UNITY_EMAIL and UNITY_PASSWORD; for a Pro/serial licence UNITY_SERIAL instead of UNITY_LICENSE. GameCI's documentation explains how to obtain each.

yaml
# .github/workflows/unity.yml
name: Unity build

on:
  push:
    branches: [main]
    tags: ['v*']
  pull_request:

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
        with:
          lfs: true                       # get the real textures, not LFS pointers
      - uses: actions/cache@v4
        with:
          path: Library
          key: Library-test-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
          restore-keys: Library-test-
      - uses: game-ci/unity-test-runner@v4
        env:
          UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
          UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
          UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
        with:
          testMode: all

  build:
    needs: test
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        targetPlatform: [StandaloneWindows64, StandaloneLinux64, WebGL]
    steps:
      - uses: actions/checkout@v5
        with:
          fetch-depth: 0                  # full history, so versioning can read tags
          lfs: true
      - uses: actions/cache@v4
        with:
          path: Library
          key: Library-${{ matrix.targetPlatform }}-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
          restore-keys: Library-${{ matrix.targetPlatform }}-
      - uses: game-ci/unity-builder@v6
        id: build
        env:
          UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
          UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
          UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
        with:
          targetPlatform: ${{ matrix.targetPlatform }}
          versioning: Semantic            # version from the last tag + commits since
      - uses: actions/upload-artifact@v4
        with:
          name: Build-${{ matrix.targetPlatform }}-${{ steps.build.outputs.buildVersion }}
          path: build/${{ matrix.targetPlatform }}

What each part buys you:

  • lfs: true: without it the build contains LFS pointer files instead of art (Git LFS & .gitattributes).
  • Caching Library/: Unity's import cache. Without it every run re-imports every asset, which can take far longer than the build itself.
  • The matrix builds each platform in parallel; fail-fast: false lets the others finish when one fails.
  • versioning: Semantic derives the version from tags; the builder exposes it as the buildVersion output.
  • The artifact is a zip anyone on the team can download from the run page: QA tests exactly what CI built.

GameCI's builder also accepts buildMethod (your own -executeMethod build script), customParameters, unityVersion (default: read from ProjectSettings/ProjectVersion.txt) and Android signing inputs. Windows-only targets (some IL2CPP and console builds) need a windows-latest or self-hosted runner.

Godot without a marketplace action

For Godot you can download the official editor and export templates directly; the steps are just shell commands:

yaml
# .github/workflows/godot.yml
name: Godot export
on: [push, pull_request]

env:
  GODOT_VERSION: 4.7.2

jobs:
  export:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
        with:
          lfs: true
      - name: Install Godot and export templates
        run: |
          base=https://github.com/godotengine/godot/releases/download/${GODOT_VERSION}-stable
          curl -sSL -o godot.zip  "$base/Godot_v${GODOT_VERSION}-stable_linux.x86_64.zip"
          curl -sSL -o templates.tpz "$base/Godot_v${GODOT_VERSION}-stable_export_templates.tpz"
          unzip -q godot.zip && mv Godot_v${GODOT_VERSION}-stable_linux.x86_64 godot
          mkdir -p ~/.local/share/godot/export_templates/${GODOT_VERSION}.stable
          unzip -q templates.tpz -d tpl && mv tpl/templates/* ~/.local/share/godot/export_templates/${GODOT_VERSION}.stable/
      - name: Export
        run: |
          mkdir -p builds/linux builds/web
          ./godot --headless --path . --export-release "Linux" builds/linux/game.x86_64
          ./godot --headless --path . --export-release "Web" builds/web/index.html
      - uses: actions/upload-artifact@v4
        with:
          name: web
          path: builds/web

The preset names ("Linux", "Web") must match export_presets.cfg exactly.

Unreal Engine

Unreal builds are large (the engine itself is tens of gigabytes) and usually run on self-hosted runners: a build machine with the engine installed (or built from source), Visual Studio, and the platform SDKs. The workflow step is just the RunUAT BuildCookRun command; Epic's own system for this is Horde, and many studios use TeamCity or Jenkins. Keep the derived data cache (DDC) on fast shared storage so cooks don't start from zero.

Deploying from CI

Builds triggered by a tag can be uploaded straight to a store. For itch.io, butler reads its key from BUTLER_API_KEY (Publishing on itch.io):

yaml
  deploy:
    if: startsWith(github.ref, 'refs/tags/v')
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/download-artifact@v4
        with:
          name: Build-WebGL-${{ needs.build.outputs.version }}   # expose the version as a job output
          path: web
      - name: Push to itch.io
        env:
          BUTLER_API_KEY: ${{ secrets.BUTLER_API_KEY }}
        run: |
          curl -sSL -o butler.zip https://broth.itch.zone/butler/linux-amd64/LATEST/archive/default
          unzip -q butler.zip && chmod +x butler
          ./butler push web yourname/star-catcher:html5 --userversion "${GITHUB_REF_NAME#v}"

(For needs.build.outputs.version to exist, the build job declares outputs: version: ${{ steps.build.outputs.buildVersion }}; with a matrix, pick a fixed artifact name instead.) Steam uploads work the same way with steamcmd and a cached Steam Guard login (Steam: Steamworks & SteamPipe).

A runnable model: what does CI rebuild?

Caches only help if their keys change when, and only when, the inputs change. A cache key is a hash of the files that affect the cached data, which is easy to model:

python · try it yourself
import hashlib

def cache_key(prefix, files, patterns):
    h = hashlib.sha256()
    for path in sorted(files):
        if any(path.startswith(p) for p in patterns):
            h.update(path.encode())
            h.update(files[path].encode())
    return f"{prefix}-{h.hexdigest()[:12]}"

inputs = ("Assets/", "Packages/", "ProjectSettings/")
commit1 = {"Assets/Hero.png": "v1", "Packages/manifest.json": "a", "README.md": "hello"}
commit2 = dict(commit1, **{"README.md": "hello world"})          # docs change only
commit3 = dict(commit2, **{"Assets/Hero.png": "v2"})              # an asset changed

for name, files in [("commit 1", commit1), ("commit 2 (README)", commit2), ("commit 3 (texture)", commit3)]:
    print(f"{name:<19} {cache_key('Library-WebGL', files, inputs)}")
commit 1            Library-WebGL-2a823a7901be
commit 2 (README)   Library-WebGL-2a823a7901be
commit 3 (texture)  Library-WebGL-25aff487d708

The README change keeps the key, so the cached Library/ is reused exactly; the texture change produces a new key, and restore-keys then falls back to the most recent Library-WebGL- cache so only the changed asset is re-imported.

Test yourself

Why does a Unity CI workflow cache the Library folder?

  1. It contains the source code
  2. It's Unity's import cache; without it every run re-imports every asset
  3. GameCI requires it
  4. To store the build output

What happens if the checkout step doesn't fetch LFS files?

  1. The build fails to start
  2. The build may succeed but contain pointer files instead of real assets
  3. GitHub downloads them anyway
  4. Nothing, LFS is optional

Which secrets does GameCI's Unity builder need for a Personal licence?

  1. UNITY_SERIAL only
  2. UNITY_LICENSE, UNITY_EMAIL and UNITY_PASSWORD
  3. GITHUB_TOKEN only
  4. None