Skip to content

Commit f008889

Browse files
mrdavidgagnonclaude
andcommitted
Separate the Unity build, DoIT deploy and Vault CDN preview into independent jobs
build (fielddaylab/vault-publisher unity-build.yml@v1) uploads one artifact; 'doit' (legacy VPN + rsync) and 'preview' (Vault staging CDN) each deploy it and don't depend on each other. The VPN now connects right before the rsync instead of before the 45-minute build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 6fbe4d7 commit f008889

1 file changed

Lines changed: 46 additions & 102 deletions

File tree

‎.github/workflows/build-webgl.yml‎

Lines changed: 46 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,128 +1,35 @@
11
name: Spacefab Build
22

3-
# Controls when the action will run. Triggers the workflow on creation of
4-
# tags. Creating new 'versions' via github is the most straightforward
5-
# way of doing this.
3+
# One Unity build, deployed independently to:
4+
# - the Vault staging CDN: https://cdn.vaultlearninggames-staging.org/fielddaylab/spacefab/<branch>/
5+
# - the DoIT server (legacy; delete the `doit` job when DoIT is retired)
6+
# The two deploys don't depend on each other. Deleting a branch removes its CDN preview.
67
on:
78
push:
89
delete:
910
workflow_dispatch:
10-
11+
1112
concurrency:
13+
# Branch-delete runs get their own group so they never cancel a build of the default branch.
1214
group: ${{ github.workflow }}-${{ github.event_name == 'delete' && github.run_id || github.ref }}
1315
cancel-in-progress: true
1416

1517
jobs:
1618
build:
17-
name: Build Unity Project
1819
if: github.event_name != 'delete'
19-
runs-on: ubuntu-latest
20-
concurrency:
21-
group: ${{ github.workflow }}
22-
queue: max
23-
24-
# Setup Steps
25-
26-
steps:
27-
28-
- name: Free disk space
29-
run: curl -fsSL https://raw.githubusercontent.com/kou/arrow/e49d8ae15583ceff03237571569099a6ad62be32/ci/scripts/util_free_space.sh | bash
30-
31-
- name: Install OpenConnect
32-
run: sudo NEEDRESTART_MODE=a sudo apt-get update && sudo apt-get install openconnect
33-
34-
- name: Connect to VPN
35-
run: echo ${{ secrets.FIELDDAY_VPN_PASSWORD }} | sudo openconnect --protocol=gp -u ${{ secrets.FIELDDAY_VPN_USERNAME }} --passwd-on-stdin soe.vpn.wisc.edu &
36-
37-
- name: Checkout repository
38-
uses: actions/checkout@v4
39-
with:
40-
lfs: true
41-
42-
- name: Checkout submodules
43-
uses: srt32/git-actions@v0.0.3
44-
with:
45-
args: |
46-
git config --global --add safe.directory "/github/workspace"
47-
git config --global --add safe.directory "/github/workspace/Submodules"
48-
git submodule update --init --recursive
49-
50-
# Extracts branch name into BRANCH environment variable
51-
- name: Extract branch name
52-
shell: bash
53-
run: echo "BRANCH=$(echo ${GITHUB_REF#refs/heads/} | sed 's/\//_/g')" >> $GITHUB_ENV
54-
55-
# Extracts version tag into VERSION environment variable
56-
- name: Extract version name
57-
shell: bash
58-
run: echo "VERSION=$(echo ${GITHUB_REF#refs/tags/} | sed 's/\//_/g')" >> $GITHUB_ENV
20+
uses: fielddaylab/vault-publisher/.github/workflows/unity-build.yml@v1
21+
secrets: inherit
5922

60-
# Read editor version
61-
- name: Retrieve editor version
62-
id: getEditorVersion
63-
uses: pietrobolcato/action-read-yaml@1.1.0
64-
with:
65-
config: ${{ github.workspace }}/ProjectSettings/ProjectVersion.txt
66-
67-
- name: Extract editor version to var
68-
shell: bash
69-
run: echo "UNITY_VERSION=${{ steps.getEditorVersion.outputs['m_EditorVersion'] }}" >> $GITHUB_ENV
70-
71-
# Unity Build Steps
72-
73-
- name: Cache Library folder
74-
uses: actions/cache@v3
75-
with:
76-
path: Library
77-
key: Library
78-
79-
# Build
80-
- name: Build project
81-
uses: game-ci/unity-builder@v4
82-
env:
83-
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
84-
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
85-
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
86-
with:
87-
unityVersion: ${{ env.UNITY_VERSION }}
88-
targetPlatform: WebGL
89-
#customParameters: '-myParameter myValue -myBoolean -ThirdParameter andItsValue'
90-
91-
92-
# Deploy Steps
93-
94-
- name: Upload build as artifact
95-
uses: actions/upload-artifact@v4
96-
with:
97-
name: ${{ github.event.repository.name }}-webgl-${{ github.sha }}
98-
path: build/WebGL/WebGL/
99-
overwrite: true
100-
101-
- name: Upload to web server via rsync
102-
uses: burnett01/rsync-deployments@5.2
103-
with:
104-
switches: -avzr --delete --rsync-path="mkdir -p ${{ secrets.DEPLOY_DIR }}/${{ env.BRANCH }} && rsync"
105-
path: build/WebGL/WebGL/*
106-
remote_path: ${{ secrets.DEPLOY_DIR }}/${{ env.BRANCH }}
107-
remote_host: ${{ secrets.FIELDDAY_WISC_EDU_DEPLOY_HOST }}
108-
remote_user: ${{ secrets.FIELDDAY_WISC_EDU_DEPLOY_USER }}
109-
remote_key: ${{ secrets.FIELDDAY_WISC_EDU_DEPLOY_KEY }}
110-
111-
# Vault staging CDN preview of the same build, alongside the DoIT deploy above until DoIT is retired:
112-
# https://cdn.vaultlearninggames-staging.org/fielddaylab/spacefab/<branch>/
113-
# Runs even if the DoIT upload fails; needs only the build artifact.
11423
preview:
11524
needs: build
116-
if: ${{ !cancelled() && github.event_name != 'delete' }}
11725
permissions:
11826
contents: read
11927
id-token: write
12028
uses: fielddaylab/vault-publisher/.github/workflows/publish-preview.yml@v1
12129
with:
12230
game: spacefab
123-
artifact: ${{ github.event.repository.name }}-webgl-${{ github.sha }}
31+
artifact: ${{ needs.build.outputs.artifact }}
12432

125-
# Deleting a branch removes its preview.
12633
remove-preview:
12734
if: github.event_name == 'delete'
12835
permissions:
@@ -131,3 +38,40 @@ jobs:
13138
uses: fielddaylab/vault-publisher/.github/workflows/publish-preview.yml@v1
13239
with:
13340
game: spacefab
41+
42+
# Legacy DoIT deploy: https://fielddaylab.wisc.edu/play/spacefab/ci/<branch>/
43+
doit:
44+
needs: build
45+
runs-on: ubuntu-latest
46+
concurrency:
47+
group: doit-${{ github.workflow }}-${{ github.ref }}
48+
cancel-in-progress: true
49+
steps:
50+
- name: Download build
51+
uses: actions/download-artifact@v8
52+
with:
53+
name: ${{ needs.build.outputs.artifact }}
54+
path: build
55+
56+
- name: Install OpenConnect
57+
run: sudo NEEDRESTART_MODE=a apt-get -q update && sudo NEEDRESTART_MODE=a apt-get -q install -y openconnect
58+
59+
- name: Connect to VPN
60+
run: |
61+
echo "${{ secrets.FIELDDAY_VPN_PASSWORD }}" | sudo openconnect --protocol=gp -u "${{ secrets.FIELDDAY_VPN_USERNAME }}" --passwd-on-stdin --background soe.vpn.wisc.edu
62+
# Wait for the tunnel before uploading.
63+
for _ in $(seq 1 30); do ip link show tun0 > /dev/null 2>&1 && exit 0; sleep 2; done
64+
echo "::error::VPN tunnel did not come up"; exit 1
65+
66+
- name: Branch folder name
67+
run: echo "BRANCH=$(echo "${GITHUB_REF#refs/heads/}" | sed 's/\//_/g')" >> "$GITHUB_ENV"
68+
69+
- name: Upload to web server via rsync
70+
uses: burnett01/rsync-deployments@5.2
71+
with:
72+
switches: -avzr --delete --rsync-path="mkdir -p ${{ secrets.DEPLOY_DIR }}/${{ env.BRANCH }} && rsync"
73+
path: build/*
74+
remote_path: ${{ secrets.DEPLOY_DIR }}/${{ env.BRANCH }}
75+
remote_host: ${{ secrets.FIELDDAY_WISC_EDU_DEPLOY_HOST }}
76+
remote_user: ${{ secrets.FIELDDAY_WISC_EDU_DEPLOY_USER }}
77+
remote_key: ${{ secrets.FIELDDAY_WISC_EDU_DEPLOY_KEY }}

0 commit comments

Comments
 (0)