CI pipeline with Unity in Github Actions

featured image

We’re building a couple of demo games to demonstrate our technology for multiplayer game servers. We use Github for hosting our git repositories and when we were to select a CI/CD system we elected to test Github Actions (it’s not quite the best branded product I’ve seen?). In our past careers we’ve tried most CI/CD systems and thought that Actions looks like it could fit our needs.

A couple of our demo games are built in Unity, some in Unreal. The build pipelines are quite different depending on the game engine. I’m only going to write about Unity here, we still haven’t set up a good pipeline for Unreal.

Caveat: Different features from Github Actions are available depending on your plan with Github. The “Environments” feature is restricted to only some subscription plans.

The excellent people over at https://game.ci has already done the heavy lifting of packaging Unity builds into Github Actions (and other build tools), I can highly recommend it.

You need first to get your activation code. Follow the steps at https://game.ci/docs/github/activation. We changed it so it doesn’t trigger on all pushes, this is a one time job really. We took the results from there and added it to Github Actions -> secrets -> UNITY_LICENSE.

Second job is the actual build job. We took most of the template straight from https://game.ci/docs/github/getting-started. We added a projectPath to get our build to match our directory structure and we also added a discord notifier to notify the team what the final status of the build job was.

Complete code for this build:

name: Build

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

env:
  UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}

jobs:
  build:
    name: Build my project ✨
    runs-on: ubuntu-latest
    steps:
      # Checkout
      - name: Checkout repository
        uses: actions/checkout@v2
        with:
          lfs: true

      # Cache
      - uses: actions/cache@v1.1.0
        with:
          path: Library
          key: Library

      # Build
      - name: Build project for Windows
        uses: webbertakken/unity-builder@v0.10
        with:
          unityVersion: 2019.4.3f1
          targetPlatform: StandaloneWindows
          projectPath: Scratch

      # Output
      - uses: actions/upload-artifact@v1
        with:
          name: Build
          path: build
      
      # Status to Discord
      - name: Send status to Discord
        uses: nebularg/actions-discord-webhook@v1
        with:
          webhook_url: ${{ secrets.DISCORD_WEBHOOK }}
          status: ${{ job.status }}
        if: always() # or failure() or success()




comment icon 0

Senaste inlägg

June 4,2021   •   3 min läsning

(written in April 2021, published in June 2021) Follow-up-to-be-written soon! We started Unordinal in December 2020 with…

comment icon 0

SUBSCRIBE ON OUR NEWSLETTER