GitHub Actions Integration
Integrate Build Metrics with GameCI for automated Unity builds on GitHub Actions
Looking for self-hosted runners? See the Self-Hosted GitHub Actions guide →
Quick Start
⚡ 3-Step Setup
- Add
BUILD_METRICS_API_KEYto GitHub Secrets - Add Unity license secrets (UNITY_EMAIL, UNITY_PASSWORD, UNITY_LICENSE)
- Copy the verified workflow example below
✅ This configuration is verified and working - tested with Unity Personal license on GitHub hosted runners.
Step 1: Add Build Metrics API Key
- Get your API key from Build Metrics Dashboard
- Go to your GitHub repo → Settings → Secrets and variables → Actions
- Click "New repository secret"
- Name:
BUILD_METRICS_API_KEY - Value: Your API key (starts with
bm_)
Step 2: Unity License Setup
✅ Both Free & Paid Work!
Unity Personal (free) and Pro/Plus both work with GameCI. Setup is simple with just 2-3 GitHub secrets.
🆓 Unity Personal (Free)
3 secrets needed - email, password, and .ulf license file
📋 License File Method
- • UNITY_EMAIL
- • UNITY_PASSWORD
- • UNITY_LICENSE (contents of .ulf file)
💼 Unity Pro/Plus (Paid)
Use serial number for best results
🔑 Serial Method
- • UNITY_EMAIL
- • UNITY_PASSWORD
- • UNITY_SERIAL
Unity Personal (Free) - Email & Password
📋 How to Get Your .ulf File
Unity Personal licenses require a .ulf license file for CI/CD activation. Here's how to get it:
- Open Unity Hub → Manage Licenses
- Click "Manual Activation"
- Save the
.alffile - Upload to Unity Manual License
- Download the
.ulffile - Copy its entire contents into the
UNITY_LICENSEsecret
📖 Detailed guide: GameCI Activation Docs
Add these 3 secrets to GitHub (Repository → Settings → Secrets and variables → Actions):
UNITY_EMAILYour Unity account email
UNITY_PASSWORDYour Unity account password
💡 Tip: Avoid special characters - use alphanumeric only to prevent activation issues
UNITY_LICENSEContents of your .ulf license file
💡 Generate via Unity Hub: Manage Licenses → Manual Activation → Copy file contents
📖 Official Guide: See GameCI Activation Documentation → for detailed steps on getting your .ulf file
⚠️ Important Notes
- • Your
.ulflicense file is tied to your Unity account and machine - generate it once and store in GitHub Secrets - • If you have 2FA enabled on Unity account, you'll need to configure TOTP (see GameCI docs)
- • Personal licenses are rate-limited by Unity - avoid running too many parallel builds
- • The license file contents should be pasted as plain text into the
UNITY_LICENSEsecret
Unity Pro/Plus - Serial Number (Recommended)
For Unity Pro or Plus licenses, use your serial key instead of a license file:
UNITY_EMAILYour Unity account email
UNITY_PASSWORDYour Unity account password
UNITY_SERIALYour Unity serial key (format: XX-XXXX-XXXX-XXXX-XXXX-XXXX)
✅ Advantages
- • No manual .ulf file generation needed
- • More stable for CI/CD pipelines
- • Supports multiple concurrent builds
Step 3: Workflow Configuration
Create .github/workflows/build.yml in your repository:
📱 Android Platform Example
This workflow builds an unsigned development APK for Android. Perfect for testing and CI/CD pipelines.
- • Output: Unsigned APK (development build)
- • Disk cleanup: Prevents "No space left on device" errors (GameCI Docker images are large)
- • No keystore required for this basic setup
- • For signed release builds, see the optional keystore section below
💾 Why Disk Cleanup Instead of Caching?
GitHub hosted runners have limited disk space (~14GB free). GameCI's Unity Docker images are very large, so we free up space by removing unused Docker images and tools before building. Library folder caching can actually cause builds to fail with "No space left on device" errors.
name: Build Unity Project
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
# Free up runner disk space
- name: Free up runner disk space
run: |
df -h
sudo docker image prune --all --force
sudo docker builder prune --all --force
sudo rm -rf /opt/hostedtoolcache/*
sudo apt clean
df -h
# Checkout repository
- name: Checkout Repository
uses: actions/checkout@v4
with:
lfs: true
fetch-depth: 0 # Full git history for commit tracking
# Build with Unity (license activation happens automatically)
- name: Build Project
uses: game-ci/unity-builder@v4
env:
BUILD_METRICS_API_KEY: ${{ secrets.BUILD_METRICS_API_KEY }}
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
# Unity Pro/Plus (Paid) - Comment out above, uncomment below
# UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
# UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
# UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
with:
customParameters: "-development -BUILD_METRICS_API_KEY ${{ secrets.BUILD_METRICS_API_KEY }}"
targetPlatform: Android
unityVersion: auto
buildName: MyGame
# Upload build artifacts
- name: Upload Build
uses: actions/upload-artifact@v4
with:
name: Build-Android
path: build/Android
# Build Metrics uploads automatically after Unity build completes!
# View results at: https://app.buildmetrics.moonlightember.com✅ How It Works
- 1. Free up disk space to prevent "No space left on device" errors
- 2. Unity license activates automatically using
env:variables (UNITY_EMAIL, UNITY_PASSWORD, UNITY_LICENSE) - 3. GameCI's
unity-builderruns Unity in Docker with your build settings - 4. Build Metrics API key is passed via
customParametersto Unity (Docker doesn't expose env vars to Unity) - 5. Build Metrics plugin detects the API key from command line and uploads metrics automatically
- 6. View results in your Build Metrics dashboard
💡 Important Tips
- • Personal License: Needs 3 secrets - UNITY_EMAIL, UNITY_PASSWORD, and UNITY_LICENSE (contents of .ulf file)
- • Pro/Plus License: Use UNITY_EMAIL, UNITY_PASSWORD, and UNITY_SERIAL
- • No separate activation step needed - GameCI v4 handles it automatically in the build step
- • Critical for Build Metrics: API key MUST be in
customParameters- env vars don't reach Unity in Docker - • License credentials: Go in
env:block, NOT inwith:inputs - • See official guide: GameCI Activation Documentation
⚠️ Unity Project Not in Repository Root?
If your Unity project is in a subfolder (e.g., MyUnityProject/ instead of repository root), add projectPath:
# Update build step - add projectPath
- name: Build Project
uses: game-ci/unity-builder@v4
env:
BUILD_METRICS_API_KEY: ${{ secrets.BUILD_METRICS_API_KEY }}
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
customParameters: "-development -BUILD_METRICS_API_KEY ${{ secrets.BUILD_METRICS_API_KEY }}"
projectPath: MyUnityProject # <-- Add this
targetPlatform: Android
unityVersion: auto
buildName: MyGameReference: Signed Release Builds with Keystore
For signed release APKs ready for Google Play Store, you'll need Android keystore signing. Build Metrics works the same way - just add the highlighted lines below to your signed build workflow.
Additional Secrets Needed
Beyond the standard secrets (BUILD_METRICS_API_KEY, UNITY_EMAIL, UNITY_PASSWORD, UNITY_LICENSE), add these keystore secrets to GitHub:
ANDROID_KEYSTORE_BASE64Base64-encoded keystore file
ANDROID_KEYSTORE_PASSKeystore password
ANDROID_KEYALIAS_NAMEKey alias name
ANDROID_KEYALIAS_PASSKey alias password
Build Metrics Integration
The key difference: Build Metrics uses the same highlighted configuration as the basic setup.
- name: Build Signed Release
uses: game-ci/unity-builder@v4
env:
BUILD_METRICS_API_KEY: ${{ secrets.BUILD_METRICS_API_KEY }}
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
customParameters: "-BUILD_METRICS_API_KEY ${{ secrets.BUILD_METRICS_API_KEY }}"
targetPlatform: Android
androidKeystoreName: user.keystore
androidKeystorePass: ${{ secrets.ANDROID_KEYSTORE_PASS }}
androidKeyaliasName: ${{ secrets.ANDROID_KEYALIAS_NAME }}
androidKeyaliasPass: ${{ secrets.ANDROID_KEYALIAS_PASS }}✅ Result
- • Build Metrics automatically tracks signed builds
- • Same API key configuration as development builds
- • Works with both APK and AAB (Android App Bundle)
📖 Learn More
For complete keystore setup instructions, see GameCI Android Build Documentation →
Reference: Multi-Platform Matrix Builds
To build for multiple platforms in parallel (Android, iOS, WebGL, Windows, etc.), use GitHub Actions matrix strategy. Build Metrics integration is the same - just add the highlighted configuration to your matrix build.
Matrix Strategy Example
The key parts: use strategy.matrix to define platforms, and Build Metrics tracks each one separately.
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
targetPlatform:
- Android
- iOS
- WebGL
- StandaloneWindows64
env:
BUILD_METRICS_API_KEY: ${{ secrets.BUILD_METRICS_API_KEY }}
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
steps:
# ... checkout, disk cleanup, etc ...
- name: Build Project
uses: game-ci/unity-builder@v4
env:
BUILD_METRICS_API_KEY: ${{ secrets.BUILD_METRICS_API_KEY }}
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
customParameters: "-development -BUILD_METRICS_API_KEY ${{ secrets.BUILD_METRICS_API_KEY }}"
targetPlatform: ${{ matrix.targetPlatform }}
unityVersion: auto✅ Result
- • Each platform builds in parallel (faster CI/CD)
- • Build Metrics tracks each platform separately
- • Dashboard shows builds grouped by platform
- • Same API key works for all platforms
📖 Learn More
For complete matrix build setup, see GameCI Matrix Build Documentation →
Troubleshooting
⚠️ License Activation Fails
Error:
"Invalid credentials" or "License activation failed"
Unity Personal: Verify UNITY_EMAIL and UNITY_PASSWORD are correct. Check for 2FA issues.
Unity Pro: Verify UNITY_LICENSE base64 encoding is correct (no line breaks)
Check: Unity version in workflow matches your project's Unity version
📊 Build Succeeds But Metrics Don't Upload
- • Verify
BUILD_METRICS_API_KEYsecret is set correctly - • Check GitHub Actions logs for "Build Metrics" output
- • Ensure API key is active in Build Metrics dashboard
- • Verify build actually completed successfully (check exit code)
🐌 Slow Builds
- • Add Library caching (see examples above)
- • Use
fetch-depth: 1instead offetch-depth: 0if you don't need git history - • Consider self-hosted runners for larger projects
Next Steps
Self-Hosted Runners →
Use your own build machines with custom Unity setups and build profiles
Offline Mode →
Track builds locally without internet connection
📚 More Examples
Find complete workflow examples in the GitHub repository:
View workflow examples on GitHub →