|

⚙️ Post #2: Setting Up Unity Continuous Integration with GitHub Actions

Genesis of Infrastructure — Entry #2
By Emergent Dynamics, building Colonies: Genesis of E.D.E.N.

Welcome back to the series. Now that your Unity project is under version control and structurally clean, you’re ready to add a powerful next step:
Continuous Integration — or CI.

This post shows you how to automate Unity builds and tests with GitHub Actions, all for free.


🧠 What Is CI and Why Use It?

CI (Continuous Integration) means automatically validating your code every time you push to Git.

For Unity, this lets you:

  • ✅ Catch build errors before they become blockers
  • ✅ Run simulation or gameplay tests headlessly
  • ✅ Generate performance logs per commit
  • ✅ Enforce quality gates (linting, test coverage)
  • ✅ Future-proof for team collaboration or open source

In short: your computer no longer has to do everything manually.


🧰 What You Need

  • A Unity project pushed to GitHub
  • A GitHub repository (public or private)
  • Unity Editor version 2021.3.45f1 or compatible
  • GitHub Actions enabled (enabled by default on new repos)

🗂 Folder Layout Recap

We assume you are using this structure:

Assets/
External/
ProjectSettings/
Packages/
.gitignore
README.md
.github/
└── workflows/
    └── unity-ci.yml      # CI pipeline config (we’ll create this)

🧾 Step-by-Step: Adding a Unity CI Workflow

  1. Create the folders:

In the root of your repo:

mkdir -p .github/workflows
  1. Create the CI workflow file:

Create .github/workflows/unity-ci.yml with this content:

name: Unity CI

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  build:
    name: Build Project
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Cache Unity packages
        uses: actions/cache@v4
        with:
          path: |
            ~/.unity3d
            ~/.cache/unity
          key: Library-${{ runner.os }}-${{ hashFiles('**/Packages/manifest.json') }}
          restore-keys: |
            Library-${{ runner.os }}-

      - name: Set up Unity
        uses: game-ci/unity-installer@v3
        with:
          unityVersion: 2021.3.45f1

      - name: Run Unity build
        uses: game-ci/unity-builder@v3
        with:
          targetPlatform: StandaloneWindows64

✅ This builds the project on every push to main and for each pull request.
✅ It installs Unity 2021.3.45f1 automatically using game-ci.


🧪 Add Test Execution (Optional)

Add this to the job if you have Unity EditMode or PlayMode tests:

      - name: Run Unity tests
        uses: game-ci/unity-test-runner@v3
        with:
          testMode: EditMode

You can repeat that for PlayMode or use all to run both.


🧾 Where Do CI Logs Go?

  • Every build/test run shows up in your GitHub repo under Actions
  • You’ll see:
  • ✅ ✅ Success/Failure of the Unity build
  • 🧪 Test results and logs (if configured)
  • 📉 Optional performance data (in future posts)

You never have to wonder “did this break something?” again.


🧱 Why We’re Using Unity 2021 LTS

You may notice we’re using Unity 2021.3.45f1 — the final and most stable LTS release for that year.

This was a deliberate decision. Our goals at this stage include:

  • Ensuring maximum compatibility with GitHub Actions and CI tools
  • Avoiding unnecessary upgrade churn while our infrastructure matures
  • Locking in a stable base to support deep systems like geodesic weather, orbital physics, and AI-driven contracts

We’ll migrate forward only when there’s a clear benefit, not just for shiny new features. For now, reliability > recency.


🔚 Wrap-Up

You now have a working CI pipeline!
Next up, you can:

  • Add artifact upload (zipped builds)
  • Track performance regressions
  • Auto-run unit tests on every pull request
  • Monitor system tick times for optimization

This is one of the biggest force multipliers in your toolbelt.
Even solo, even early — CI pays off.

With just a few files, you’ve now:

  • Set up a version-controlled Unity project
  • Ignored temp files the right way
  • Connected it to GitHub Actions for automated builds
  • Opened the door to testing and profiling infrastructure

Next Entry: Automated Testing, Simulation Profiling, and Performance Logging in Unity CI

Similar Posts

Leave a Reply