Using GitHub Actions to build Unreal models

We maintain a reference model which is continuously built and deployed using GitHub Actions. To do this, you can create a self-hosted GitHub runner. This runner could be deployed on your local infrastructure or AWS. Provision this machine with the Unreal Engine required.

https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners

name:  Unreal Build

# Trigger on every master branch push and pull request
on:
  push:
    branches:
      - master
      - develop
jobs:

  build:
    runs-on: [self-hosted, unreal]
    env:
      PROJECT_NAME: ${{ github.event.repository.name }}
    steps:

    - run: Get-PSDrive
    - name: Checkout
      uses: actions/checkout@v2

    - name: Create LFS file list
      run: git lfs ls-files |  ForEach-Object { $_.split(" ")[0]  } | Sort-Object | Out-File -FilePath .lfs-assets-id

    - name: Restore LFS cache
      uses: actions/cache@v2
      id: lfs-cache
      with:
        path: .git/lfs
        key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}-v1

    - name: Git LFS Pull
      run: git lfs pull

    - name: Setup .npmrc file to publish to npm
      uses: actions/setup-node@v2-beta
      with:
        node-version: '14'
        registry-url: 'https://npm.pkg.github.com'

 
    - name: Install the PureWeb CLI
      run: npm install -g @pureweb/platform-cli@3.5.0

    - name: Set the client ID
    # Obtained from the Project Settings at console.pureweb.io in the console-admins account
      run: pw config set client-id XXXX

    - name: Set the client secret
    # Obtained from the Project Settings at console.pureweb.io in the console-admins account
      run: pw config set client-secret YYYY

    - run: Invoke-Build Setup

    - run: Invoke-Build Build
    
    - run: Invoke-Build PostBuild

    - name: Upload model to PureWeb console
      run: pw model create PureWebReferenceGame-426 "artifacts/PureWebReferenceGame.zip" --exe “platform-ref-game/PureWebReferenceGame.exe”
Example GitHub Workflow

We use Invoke-Build to drive our Windows builds: https://github.com/nightroman/Invoke-Build

These scripts are calling into Unreal’s BuildCookRun tools, zipping the packaged game and placing it into the artifacts folder.