Skip to content

Commit c1cf6bf

Browse files
Use environment variables to improve GitHub workflow readability (#974)
* Use environment variables to improve GitHub workflow readability * Fix shell quoting and variable expansion in GitHub Actions workflows * Update .github/workflows/test-linux.yml * Refactor GitHub workflows to use environment variables for clarity * Fix Windows path separators in GitHub Actions workflow --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com>
1 parent 2d2fa72 commit c1cf6bf

File tree

6 files changed

+87
-39
lines changed

6 files changed

+87
-39
lines changed

.github/workflows/sdk-build.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,23 @@ jobs:
3636

3737
- name: Select submodule
3838
id: env
39+
env:
40+
TARGET: ${{ inputs.target }}
3941
run: |
40-
if [[ "${{ inputs.target }}" == "Android" ]]; then
42+
if [[ "$TARGET" == "Android" ]]; then
4143
submodule="modules/sentry-java"
4244
else
4345
submodule="modules/sentry-native"
4446
fi
4547
echo "submodule=$submodule" >> $GITHUB_OUTPUT
46-
echo "path=plugin-dev/Source/ThirdParty/${{ inputs.target }}" >> $GITHUB_OUTPUT
47-
echo "buildScript=scripts/build-$(echo '${{ inputs.target }}' | tr '[:upper:]' '[:lower:]').sh" >> $GITHUB_OUTPUT
48+
echo "path=plugin-dev/Source/ThirdParty/$TARGET" >> $GITHUB_OUTPUT
49+
echo "buildScript=scripts/build-$(echo "$TARGET" | tr '[:upper:]' '[:lower:]').sh" >> $GITHUB_OUTPUT
4850
4951
- name: Get submodule status
52+
env:
53+
SUBMODULE: ${{ steps.env.outputs.submodule }}
5054
run: |
51-
git submodule status --cached ${{ steps.env.outputs.submodule }} | tee submodule-status
55+
git submodule status --cached "$SUBMODULE" | tee submodule-status
5256
5357
- uses: actions/cache@v4
5458
id: cache
@@ -84,10 +88,14 @@ jobs:
8488

8589
- name: Build
8690
if: steps.cache.outputs.cache-hit != 'true'
91+
env:
92+
SUBMODULE: ${{ steps.env.outputs.submodule }}
93+
BUILD_PATH: ${{ steps.env.outputs.path }}
94+
BUILD_SCRIPT: ${{ steps.env.outputs.buildScript }}
8795
run: |
88-
git submodule update --init --recursive ${{ steps.env.outputs.submodule }}
89-
mkdir -p '${{ steps.env.outputs.path }}'
90-
${{ steps.env.outputs.buildScript }} '${{ steps.env.outputs.submodule }}' '${{ steps.env.outputs.path }}'
96+
git submodule update --init --recursive "$SUBMODULE"
97+
mkdir -p "$BUILD_PATH"
98+
"$BUILD_SCRIPT" "$SUBMODULE" "$BUILD_PATH"
9199
92100
- uses: actions/upload-artifact@v4
93101
with:

.github/workflows/sdk-download.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ jobs:
2020

2121
- name: Select properties file
2222
id: env
23+
env:
24+
TARGET: ${{ inputs.target }}
2325
run: |
24-
if [[ "${{ inputs.target }}" == "IOS" || "${{ inputs.target }}" == "Mac" ]]; then
26+
if [[ "$TARGET" == "IOS" || "$TARGET" == "Mac" ]]; then
2527
echo "cacheLocation=modules/sentry-cocoa" >> $GITHUB_OUTPUT
2628
echo "propertiesFile=modules/sentry-cocoa.properties" >> $GITHUB_OUTPUT
2729
echo "downloadScript=scripts/download-cocoa.sh" >> $GITHUB_OUTPUT
2830
fi
29-
echo "path=plugin-dev/Source/ThirdParty/${{ inputs.target }}" >> $GITHUB_OUTPUT
31+
echo "path=plugin-dev/Source/ThirdParty/$TARGET" >> $GITHUB_OUTPUT
3032
3133
- uses: actions/cache@v4
3234
id: cache
@@ -37,9 +39,13 @@ jobs:
3739

3840
- name: Download
3941
if: steps.cache.outputs.cache-hit != 'true'
42+
env:
43+
DOWNLOAD_PATH: ${{ steps.env.outputs.path }}
44+
DOWNLOAD_SCRIPT: ${{ steps.env.outputs.downloadScript }}
45+
CACHE_LOCATION: ${{ steps.env.outputs.cacheLocation }}
4046
run: |
41-
mkdir -p '${{ steps.env.outputs.path }}'
42-
${{ steps.env.outputs.downloadScript }} '${{ steps.env.outputs.cacheLocation }}' '${{ steps.env.outputs.path }}'
47+
mkdir -p "$DOWNLOAD_PATH"
48+
"$DOWNLOAD_SCRIPT" "$CACHE_LOCATION" "$DOWNLOAD_PATH"
4349
4450
- uses: actions/upload-artifact@v4
4551
with:

.github/workflows/test-linux.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ jobs:
4545
password: ${{ secrets.GITHUB_TOKEN }}
4646

4747
- name: Start Docker container
48+
env:
49+
WORKSPACE_PATH: ${{ github.workspace }}
50+
UNREAL_VERSION: ${{ inputs.unreal-version }}
4851
run: |
4952
# We start the container with the user ID of the parent GH action user to avoid permission issues on volume.
5053
# For UE 5.4 we have to enable ipv6 to fix container startup issues. See https://github.com/adamrehn/ue4-docker/issues/357
@@ -55,13 +58,13 @@ jobs:
5558
docker network create --ipv6 --subnet 2001:0DB8::/112 ip6net
5659
docker run -td \
5760
--name unreal \
58-
--volume ${{ github.workspace }}:/workspace \
61+
--volume "$WORKSPACE_PATH:/workspace" \
5962
--workdir /workspace \
6063
--user $uid:$gid \
6164
--env HOME="/home/$user" \
6265
--env PATH="/home/$user/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \
6366
--network ip6net -p 80:80 \
64-
ghcr.io/getsentry/unreal-docker:${{ inputs.unreal-version }}-linux
67+
ghcr.io/getsentry/unreal-docker:"$UNREAL_VERSION"-linux
6568
docker logout ghcr.io
6669
# Add the user so it has a home directory (needed to run tests later on)
6770
docker exec --user root unreal useradd -u $uid -g $gid --create-home $user
@@ -73,11 +76,13 @@ jobs:
7376
# Chown some paths to the GH user to make UE5 work properly. We can't just chown the whole UnrealEngine or
7477
# docker would implicitly have to copy it to the container and we would run out of space on the GH runner.
7578
- name: Chown Docker container paths
79+
env:
80+
ENGINE_PATH: ${{ inputs.unreal-version == '4.27' && 'Programs/UnrealPak/Saved' || 'Binaries/ThirdParty/DotNet' }}
7681
run: |
7782
uid=$(id -u) # the GH action user ID
7883
docker exec --user root unreal bash -c "
7984
chown -R $uid /home/ue4/UnrealEngine/Engine/Binaries/ThirdParty/Mono/Linux ;
80-
chown -R $uid /home/ue4/UnrealEngine/Engine/${{ inputs.unreal-version == '4.27' && 'Programs/UnrealPak/Saved' || 'Binaries/ThirdParty/DotNet' }} ;
85+
chown -R $uid /home/ue4/UnrealEngine/Engine/\"$ENGINE_PATH\" ;
8186
chown -R $uid /home/ue4/UnrealEngine/Engine/Binaries/ThirdParty/USD/UsdResources/Linux ;
8287
mkdir -p /home/ue4/UnrealEngine/Epic/UnrealEngine && chown -R $uid /home/ue4/UnrealEngine/Epic ;
8388
mkdir -p /home/ue4/UnrealEngine/Engine/Source/Epic/UnrealEngine && chown -R $uid /home/ue4/UnrealEngine/Engine/Source/Epic ;
@@ -94,14 +99,18 @@ jobs:
9499
submodules: recursive
95100

96101
- name: Extract package to sample/Plugins
97-
run: unzip sentry-unreal-*-engine${{ inputs.unreal-version }}-github.zip -d checkout/sample/Plugins/sentry
102+
env:
103+
UNREAL_VERSION: ${{ inputs.unreal-version }}
104+
run: unzip sentry-unreal-*-engine"$UNREAL_VERSION"-github.zip -d checkout/sample/Plugins/sentry
98105

99106
- name: Set permissions for sample
100107
# sentry-native requires write access to sample project directory in order to initialize itself properly
101108
run: docker exec -w /workspace/checkout unreal chmod -R +x sample
102109

103110
- name: Run tests
104111
id: run-tests
112+
env:
113+
EDITOR_BINARY: ${{ inputs.unreal-version == '4.27' && 'UE4Editor' || 'UnrealEditor' }}
105114
run: |
106115
docker exec -w /workspace/checkout/sample unreal bash -c "
107116
ls -al /workspace/checkout/sample/Plugins/sentry "
@@ -118,7 +127,7 @@ jobs:
118127
-archive
119128
docker exec -w /workspace/checkout/sample unreal bash -c "
120129
cp -r '/home/gh/Library/Logs/Unreal Engine/LocalBuildLogs' Saved/Logs "
121-
docker exec -w /workspace/checkout/sample unreal /home/ue4/UnrealEngine/Engine/Binaries/Linux/${{ inputs.unreal-version == '4.27' && 'UE4Editor' || 'UnrealEditor' }} \
130+
docker exec -w /workspace/checkout/sample unreal /home/ue4/UnrealEngine/Engine/Binaries/Linux/"$EDITOR_BINARY" \
122131
/workspace/checkout/sample/SentryPlayground.uproject \
123132
-ReportExportPath=/workspace/checkout/sample/Saved/Automation \
124133
-ExecCmds="Automation RunTests Sentry;quit" \

.github/workflows/test-windows.yml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,15 @@ jobs:
2222
password: ${{ secrets.GITHUB_TOKEN }}
2323

2424
- name: Start Docker container
25+
env:
26+
WORKSPACE_PATH: ${{ github.workspace }}
27+
UNREAL_VERSION: ${{ inputs.unreal-version }}
2528
run: |
2629
docker run -td `
2730
--name unreal `
28-
--volume "${{ github.workspace }}:C:\workspace" `
29-
--workdir C:\workspace `
30-
ghcr.io/getsentry/unreal-docker:${{ inputs.unreal-version }}
31+
--volume "${env:WORKSPACE_PATH}:C:/workspace" `
32+
--workdir C:/workspace `
33+
ghcr.io/getsentry/unreal-docker:"$env:UNREAL_VERSION"
3134
3235
- name: Download package
3336
uses: actions/download-artifact@v4
@@ -40,16 +43,21 @@ jobs:
4043
submodules: recursive
4144

4245
- name: Extract package to sample/Plugins
46+
env:
47+
WORKSPACE_PATH: ${{ github.workspace }}
48+
UNREAL_VERSION: ${{ inputs.unreal-version }}
4349
run: |
44-
New-Item -ItemType Directory -Path "${{ github.workspace }}\checkout\sample\Plugins\sentry" -Force
45-
Expand-Archive -Path "sentry-unreal-*-engine${{ inputs.unreal-version }}-github.zip" -DestinationPath "${{ github.workspace }}\checkout\sample\Plugins\sentry" -Force
50+
New-Item -ItemType Directory -Path "$env:WORKSPACE_PATH\checkout\sample\Plugins\sentry" -Force
51+
Expand-Archive -Path "sentry-unreal-*-engine$env:UNREAL_VERSION-github.zip" -DestinationPath "$env:WORKSPACE_PATH\checkout\sample\Plugins\sentry" -Force
4652
4753
- name: Run tests
4854
id: run-tests
55+
env:
56+
EDITOR_BINARY: ${{ inputs.unreal-version == '4.27' && 'UE4Editor.exe' || 'UnrealEditor.exe' }}
4957
run: |
5058
docker exec unreal C:\UnrealEngine\Engine\Build\BatchFiles\RunUAT.bat BuildCookRun `
51-
-project=C:\workspace\checkout\sample\SentryPlayground.uproject `
52-
-archivedirectory=C:\workspace\checkout\sample\Builds `
59+
-project=C:/workspace/checkout/sample/SentryPlayground.uproject `
60+
-archivedirectory=C:/workspace/checkout/sample/Builds `
5361
-platform=Win64 `
5462
-nop4 `
5563
-cook `
@@ -58,8 +66,8 @@ jobs:
5866
-prereqss `
5967
-package `
6068
-archive
61-
docker exec unreal C:\UnrealEngine\Engine\Binaries\Win64\${{ inputs.unreal-version == '4.27' && 'UE4Editor.exe' || 'UnrealEditor.exe' }} C:\workspace\checkout\sample\SentryPlayground.uproject `
62-
-ReportExportPath=C:\workspace\checkout\sample\Saved\Automation `
69+
docker exec unreal "C:\UnrealEngine\Engine\Binaries\Win64\$env:EDITOR_BINARY" C:/workspace/checkout/sample/SentryPlayground.uproject `
70+
-ReportExportPath=C:/workspace/checkout/sample/Saved/Automation `
6371
-ExecCmds="Automation RunTests Sentry;quit" `
6472
-TestExit="Automation Test Queue Empty" `
6573
-Unattended `

.github/workflows/ue-docker-linux.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,17 @@ jobs:
8282
ue4-docker setup
8383
8484
- name: Build Unreal Engine Docker image
85+
env:
86+
UE_REPO: ${{ inputs.ue_repo }}
87+
UE_VERSION: ${{ inputs.ue_version }}
88+
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
89+
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
8590
run: |
86-
ue4-docker build custom -repo="${{ inputs.ue_repo }}" -branch="${{ inputs.ue_version }}" \
91+
ue4-docker build custom -repo="$UE_REPO" -branch="$UE_VERSION" \
8792
-basetag ubuntu22.04 \
88-
-suffix "${{ inputs.ue_version }}" \
89-
-username=${{ secrets.DOCKER_USERNAME }} \
90-
-password=${{ secrets.DOCKER_TOKEN }} \
93+
-suffix "$UE_VERSION" \
94+
-username="$DOCKER_USERNAME" \
95+
-password="$DOCKER_TOKEN" \
9196
--linux \
9297
--target minimal \
9398
--exclude debug \
@@ -102,6 +107,8 @@ jobs:
102107
password: ${{ secrets.GITHUB_TOKEN }}
103108

104109
- name: Tag and push Docker image with pre-built Unreal Engine
110+
env:
111+
UE_VERSION: ${{ inputs.ue_version }}
105112
run: |
106-
docker tag adamrehn/ue4-minimal:custom-${{ inputs.ue_version }} ${{ env.REGISTRY }}/getsentry/unreal-docker:${{ inputs.ue_version }}-linux
107-
docker push ${{ env.REGISTRY }}/getsentry/unreal-docker:${{ inputs.ue_version }}-linux
113+
docker tag "adamrehn/ue4-minimal:custom-$UE_VERSION" "$REGISTRY/getsentry/unreal-docker:$UE_VERSION-linux"
114+
docker push "$REGISTRY/getsentry/unreal-docker:$UE_VERSION-linux"

.github/workflows/ue-docker-windows.yml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ jobs:
5353
- name: Set Visual Studio version based on UE version
5454
id: set_vs_version
5555
shell: bash
56+
env:
57+
UE_VERSION: ${{ inputs.ue_version }}
5658
run: |
57-
if [[ "${{ inputs.ue_version }}" == "4.27" || "${{ inputs.ue_version }}" == "5.0" || "${{ inputs.ue_version }}" == "5.1" ]]; then
59+
if [[ "$UE_VERSION" == "4.27" || "$UE_VERSION" == "5.0" || "$UE_VERSION" == "5.1" ]]; then
5860
echo "vs_version=2019" >> $GITHUB_OUTPUT
5961
else
6062
echo "vs_version=2022" >> $GITHUB_OUTPUT
@@ -82,14 +84,20 @@ jobs:
8284
ue4-docker setup
8385
8486
- name: Build Unreal Engine Docker image
87+
env:
88+
UE_REPO: ${{ inputs.ue_repo }}
89+
UE_VERSION: ${{ inputs.ue_version }}
90+
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
91+
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
92+
VS_VERSION: ${{ steps.set_vs_version.outputs.vs_version }}
8593
run: |
86-
ue4-docker build custom -repo="${{ inputs.ue_repo }}" -branch="${{ inputs.ue_version }}" `
94+
ue4-docker build custom -repo="$env:UE_REPO" -branch="$env:UE_VERSION" `
8795
-basetag ltsc2022 `
88-
-suffix "${{ inputs.ue_version }}" `
96+
-suffix "$env:UE_VERSION" `
8997
-isolation=process `
90-
-username=${{ secrets.DOCKER_USERNAME }} `
91-
-password=${{ secrets.DOCKER_TOKEN }} `
92-
--visual-studio ${{ steps.set_vs_version.outputs.vs_version }} `
98+
-username="$env:DOCKER_USERNAME" `
99+
-password="$env:DOCKER_TOKEN" `
100+
--visual-studio "$env:VS_VERSION" `
93101
--target minimal `
94102
--exclude debug `
95103
--exclude templates `
@@ -104,6 +112,8 @@ jobs:
104112
password: ${{ secrets.GITHUB_TOKEN }}
105113

106114
- name: Tag and push Docker image with pre-built Unreal Engine
115+
env:
116+
UE_VERSION: ${{ inputs.ue_version }}
107117
run: |
108-
docker tag adamrehn/ue4-minimal:custom-${{ inputs.ue_version }} ${{ env.REGISTRY }}/getsentry/unreal-docker:${{ inputs.ue_version }}
109-
docker push ${{ env.REGISTRY }}/getsentry/unreal-docker:${{ inputs.ue_version }}
118+
docker tag "adamrehn/ue4-minimal:custom-$env:UE_VERSION" "$env:REGISTRY/getsentry/unreal-docker:$env:UE_VERSION"
119+
docker push "$env:REGISTRY/getsentry/unreal-docker:$env:UE_VERSION"

0 commit comments

Comments
 (0)