122 lines
5.5 KiB
YAML
122 lines
5.5 KiB
YAML
# This is a basic workflow to help you get started with Actions
|
|
|
|
name: Cloud Runner - AWS Self-Hosted Ephemeral Runner Pipeline
|
|
|
|
env:
|
|
AWS_REGION: eu-west-2
|
|
AWS_DEFAULT_REGION: eu-west-2
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
CLOUD_RUNNER_BRANCH: cloud-runner-develop
|
|
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
|
|
|
# Controls when the workflow will run
|
|
on:
|
|
# Triggers the workflow on push or pull request events but only for the develop branch
|
|
push: { branches: [main, cloud-runner-develop] }
|
|
|
|
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
|
jobs:
|
|
# This workflow contains a single job called "build"
|
|
boot-self-hosted-runner:
|
|
# The type of runner that the job will run on
|
|
runs-on: ubuntu-latest
|
|
|
|
# Steps represent a sequence of tasks that will be executed as part of the job
|
|
steps:
|
|
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
|
- uses: actions/checkout@v2
|
|
with:
|
|
lfs: 'false'
|
|
fetch-depth: 0
|
|
###########################
|
|
# Ephemeral Runner #
|
|
###########################
|
|
- name: Configure AWS Credentials
|
|
uses: aws-actions/configure-aws-credentials@v1
|
|
with:
|
|
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
- name: Unity - Builder
|
|
# You may pin to the exact commit or the version.
|
|
# uses: game-ci/unity-builder@3d0eb0805bbe2df90e319abbe42e41d0b9105625
|
|
uses: ./
|
|
with:
|
|
cloudRunnerCluster: aws
|
|
allowDirtyBuild: true
|
|
cloudRunnerMemory: 4096
|
|
cloudRunnerCpu: 2048
|
|
gitPrivateToken: ${{ secrets.GITHUB_TOKEN }}
|
|
customJob: |
|
|
- name: upload
|
|
image: ubuntu
|
|
commands: |
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
export RUNNER_ALLOW_RUNASROOT="1"
|
|
apt-get update
|
|
apt-get install -qy unzip curl libdigest-sha-perl apt-transport-https libicu-dev jq git git-lfs
|
|
mkdir -p $BUILD_GUID/actions-runner && cd $BUILD_GUID/actions-runner
|
|
curl -o actions-runner-linux-x64-2.289.2.tar.gz -L https://github.com/actions/runner/releases/download/v2.289.2/actions-runner-linux-x64-2.289.2.tar.gz
|
|
echo "7ba89bb75397896a76e98197633c087a9499d4c1db7603f21910e135b0d0a238 actions-runner-linux-x64-2.289.2.tar.gz" | shasum -a 256 -c
|
|
tar xzf ./actions-runner-linux-x64-2.289.2.tar.gz
|
|
repo="game-ci/unity-builder"
|
|
TOKEN=$(curl -X POST -H "Authorization: Bearer $GIT_PRIVATE_TOKEN" -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/$repo/actions/runners/registration-token | jq -r .token)
|
|
./config.sh --url https://github.com/$repo --token $TOKEN --ephemeral
|
|
echo "cloud runner stop watching job"
|
|
./run.sh
|
|
boot-game-ci-cloud-runner:
|
|
runs-on: self-hosted
|
|
steps:
|
|
- name: Unity - Builder
|
|
id: aws-fargate-unity-build
|
|
# You may pin to the exact commit or the version.
|
|
# uses: game-ci/unity-builder@3d0eb0805bbe2df90e319abbe42e41d0b9105625
|
|
uses: game-ci/unity-builder@cloud-runner-develop
|
|
with:
|
|
branch: ${{ github.ref }}
|
|
GITHUB_SHA: ${{ github.sha }}
|
|
cloudRunnerCluster: aws
|
|
allowDirtyBuild: true
|
|
cloudRunnerMemory: 8192
|
|
cloudRunnerCpu: 2048
|
|
gitPrivateToken: ${{ secrets.GITHUB_TOKEN }}
|
|
targetPlatform: StandaloneWindows64
|
|
postBuildSteps: |
|
|
- name: upload
|
|
image: amazon/aws-cli
|
|
commands: |
|
|
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID --profile default
|
|
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY --profile default
|
|
aws configure set region $AWS_DEFAULT_REGION --profile default
|
|
aws s3 ls
|
|
aws s3 ls game-ci-test-storage
|
|
du -s /data/cache/$CACHE_KEY
|
|
echo "build folder contents"
|
|
du -s /data/cache/$CACHE_KEY/build
|
|
find ~ -name '*exe'
|
|
aws s3 cp /data/cache/$CACHE_KEY/build/build-$BUILD_GUID.zip s3://game-ci-test-storage/$CACHE_KEY/build-$BUILD_GUID.zip
|
|
secrets:
|
|
- name: awsAccessKeyId
|
|
value: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
- name: awsSecretAccessKey
|
|
value: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
- name: awsDefaultRegion
|
|
value: eu-west-2
|
|
###########################
|
|
# Download Artifacts #
|
|
###########################
|
|
# download from cloud storage
|
|
- run: |
|
|
aws s3 cp s3://game-ci-test-storage/${{ steps.aws-fargate-unity-build.outputs.CACHE_KEY }}/build-${{ steps.aws-fargate-unity-build.outputs.BUILD_GUID }}.zip build-${{ steps.aws-fargate-unity-build.outputs.BUILD_GUID }}.zip
|
|
unzip build-${{ steps.aws-fargate-unity-build.outputs.BUILD_GUID }}.zip -d build
|
|
ls build
|
|
###########################
|
|
# Upload #
|
|
###########################
|
|
# download from cloud storage
|
|
- uses: actions/upload-artifact@v2
|
|
with:
|
|
name: AWS Build (${{ matrix.targetPlatform }})
|
|
path: build-${{ steps.aws-fargate-unity-build.outputs.BUILD_GUID }}.zip
|
|
retention-days: 14
|