GitHub Actions


Understanding the workflow file

sample 1: official one

name: learn-github-actions
run-name: ${{ github.actor }} is learning GitHub Actions
on: [push]
jobs:
  check-bats-version:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
      - run: npm install -g bats
      - run: bats -v
  • name: learn-github-actions : Optional – The name of the workflow as it will appear in the “Actions” tab of the GitHub repository. If this field is omitted, the name of the workflow file will be used instead.
  • run-name: ${{ github.actor }} is learning GitHub Actions : Optional – The name for workflow runs generated from the workflow, which will appear in the list of workflow runs on your repository’s “Actions” tab. This example uses an expression with the github context to display the username of the actor that triggered the workflow run. For more information, see “Workflow syntax for GitHub Actions.”
  • on: [push] : Specifies the trigger for this workflow. This example uses the push event, so a workflow run is triggered every time someone pushes a change to the repository or merges a pull request. This is triggered by a push to every branch; for examples of syntax that runs only on pushes to specific branches, paths, or tags, see “Workflow syntax for GitHub Actions.”
  • jobs : Groups together all the jobs that run in the learn-github-actions workflow.
  • check-bats-version : Defines a job named check-bats-version. The child keys will define properties of the job.
  • runs-on: ubuntu-latest : Configures the job to run on the latest version of an Ubuntu Linux runner. This means that the job will execute on a fresh virtual machine hosted by GitHub. For syntax examples using other runners, see “Workflow syntax for GitHub Actions
  • steps : Groups together all the steps that run in the check-bats-version job. Each item nested under this section is a separate action or shell script.
  • uses: actions/checkout@v4 : The uses keyword specifies that this step will run v4 of the actions/checkout action. This is an action that checks out your repository onto the runner, allowing you to run scripts or other actions against your code (such as build and test tools). You should use the checkout action any time your workflow will use the repository’s code.
  • uses: actions/setup-node@v4 : This step uses the actions/setup-node@v4 action to install the specified version of the Node.js. (This example uses version 20.) This puts both the node and npm commands in your PATH.
  • run: npm install -g bats : The run keyword tells the job to execute a command on the runner. In this case, you are using npm to install the bats software testing package.
  • run: bats -v : Finally, you’ll run the bats command with a parameter that outputs the software version.

sample 2: UE package

name: Package Unreal Engine Project


on:
  push:
    branches:
      - master


jobs:
  build:
    runs-on: self-hosted
    name: Package Unreal Engine Game
    steps:
      - name: Checkout code
        uses: actions/checkout@v3


      - name: Package Project
        env: 
          UE_PATH: 'D:\Epic Games\UE_5.3' # Path to your Unreal Engine installation
          PROJECT_PATH: 'D:\Game Development\Unreal Projects\CICDGO\CICDGO.uproject' # Path to your Unreal project file
          OUTPUT_PATH: 'D:\Game Development' # Path to where you want to store the packaged game
        run: |
          # Try to run empty UAT to check for correct path
          & $env:UE_PATH\Engine\Build\BatchFiles\RunUAT.bat BuildCookRun -project="$env:PROJECT_PATH" -noP4 -platform=Win64 -clientconfig=Development -serverconfig=Development -cook -allmaps -build -stage -pak -archive -archivedirectory="$env:OUTPUT_PATH"
  • runs-on: self-hosted : self-hosted means that this process will be done on our own hosted-machine. By default it’s GitHub Cloud.
  • env : Setting the variables here for this step. In my case, it is my path to unreal engine folder, project_file, and output folder.

Self-hosted runners

follow this: Adding self-hosted runners

Note: On Windows, if you want to install the self-hosted runner application as a service, you must open a shell with administrator privileges. We also recommend that you use C:\actions-runner as the directory for the self-hosted runner application so that Windows system accounts can access the runner directory.

References


Leave a Reply

Your email address will not be published. Required fields are marked *

css.php