Skip to content

Use environment variables to improve GitHub workflow readability #974

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions .github/workflows/sdk-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,23 @@ jobs:

- name: Select submodule
id: env
env:
TARGET: ${{ inputs.target }}
run: |
if [[ "${{ inputs.target }}" == "Android" ]]; then
if [[ "$TARGET" == "Android" ]]; then
submodule="modules/sentry-java"
else
submodule="modules/sentry-native"
fi
echo "submodule=$submodule" >> $GITHUB_OUTPUT
echo "path=plugin-dev/Source/ThirdParty/${{ inputs.target }}" >> $GITHUB_OUTPUT
echo "buildScript=scripts/build-$(echo '${{ inputs.target }}' | tr '[:upper:]' '[:lower:]').sh" >> $GITHUB_OUTPUT
echo "path=plugin-dev/Source/ThirdParty/$TARGET" >> $GITHUB_OUTPUT
echo "buildScript=scripts/build-$(echo "$TARGET" | tr '[:upper:]' '[:lower:]').sh" >> $GITHUB_OUTPUT
- name: Get submodule status
env:
SUBMODULE: ${{ steps.env.outputs.submodule }}
run: |
git submodule status --cached ${{ steps.env.outputs.submodule }} | tee submodule-status
git submodule status --cached "$SUBMODULE" | tee submodule-status
- uses: actions/cache@v4
id: cache
Expand Down Expand Up @@ -84,10 +88,14 @@ jobs:

- name: Build
if: steps.cache.outputs.cache-hit != 'true'
env:
SUBMODULE: ${{ steps.env.outputs.submodule }}
BUILD_PATH: ${{ steps.env.outputs.path }}
BUILD_SCRIPT: ${{ steps.env.outputs.buildScript }}
run: |
git submodule update --init --recursive ${{ steps.env.outputs.submodule }}
mkdir -p '${{ steps.env.outputs.path }}'
${{ steps.env.outputs.buildScript }} '${{ steps.env.outputs.submodule }}' '${{ steps.env.outputs.path }}'
git submodule update --init --recursive "$SUBMODULE"
mkdir -p "$BUILD_PATH"
"$BUILD_SCRIPT" "$SUBMODULE" "$BUILD_PATH"
- uses: actions/upload-artifact@v4
with:
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/sdk-download.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ jobs:

- name: Select properties file
id: env
env:
TARGET: ${{ inputs.target }}
run: |
if [[ "${{ inputs.target }}" == "IOS" || "${{ inputs.target }}" == "Mac" ]]; then
if [[ "$TARGET" == "IOS" || "$TARGET" == "Mac" ]]; then
echo "cacheLocation=modules/sentry-cocoa" >> $GITHUB_OUTPUT
echo "propertiesFile=modules/sentry-cocoa.properties" >> $GITHUB_OUTPUT
echo "downloadScript=scripts/download-cocoa.sh" >> $GITHUB_OUTPUT
fi
echo "path=plugin-dev/Source/ThirdParty/${{ inputs.target }}" >> $GITHUB_OUTPUT
echo "path=plugin-dev/Source/ThirdParty/$TARGET" >> $GITHUB_OUTPUT

- uses: actions/cache@v4
id: cache
Expand All @@ -37,9 +39,13 @@ jobs:

- name: Download
if: steps.cache.outputs.cache-hit != 'true'
env:
DOWNLOAD_PATH: ${{ steps.env.outputs.path }}
DOWNLOAD_SCRIPT: ${{ steps.env.outputs.downloadScript }}
CACHE_LOCATION: ${{ steps.env.outputs.cacheLocation }}
run: |
mkdir -p '${{ steps.env.outputs.path }}'
${{ steps.env.outputs.downloadScript }} '${{ steps.env.outputs.cacheLocation }}' '${{ steps.env.outputs.path }}'
mkdir -p "$DOWNLOAD_PATH"
"$DOWNLOAD_SCRIPT" "$CACHE_LOCATION" "$DOWNLOAD_PATH"

- uses: actions/upload-artifact@v4
with:
Expand Down
19 changes: 14 additions & 5 deletions .github/workflows/test-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

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

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

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

- name: Run tests
id: run-tests
env:
EDITOR_BINARY: ${{ inputs.unreal-version == '4.27' && 'UE4Editor' || 'UnrealEditor' }}
run: |
docker exec -w /workspace/checkout/sample unreal bash -c "
ls -al /workspace/checkout/sample/Plugins/sentry "
Expand All @@ -118,7 +127,7 @@ jobs:
-archive
docker exec -w /workspace/checkout/sample unreal bash -c "
cp -r '/home/gh/Library/Logs/Unreal Engine/LocalBuildLogs' Saved/Logs "
docker exec -w /workspace/checkout/sample unreal /home/ue4/UnrealEngine/Engine/Binaries/Linux/${{ inputs.unreal-version == '4.27' && 'UE4Editor' || 'UnrealEditor' }} \
docker exec -w /workspace/checkout/sample unreal /home/ue4/UnrealEngine/Engine/Binaries/Linux/"$EDITOR_BINARY" \
/workspace/checkout/sample/SentryPlayground.uproject \
-ReportExportPath=/workspace/checkout/sample/Saved/Automation \
-ExecCmds="Automation RunTests Sentry;quit" \
Expand Down
26 changes: 17 additions & 9 deletions .github/workflows/test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

- name: Start Docker container
env:
WORKSPACE_PATH: ${{ github.workspace }}
UNREAL_VERSION: ${{ inputs.unreal-version }}
run: |
docker run -td `
--name unreal `
--volume "${{ github.workspace }}:C:\workspace" `
--workdir C:\workspace `
ghcr.io/getsentry/unreal-docker:${{ inputs.unreal-version }}
--volume "${env:WORKSPACE_PATH}:C:/workspace" `
--workdir C:/workspace `
ghcr.io/getsentry/unreal-docker:"$env:UNREAL_VERSION"

- name: Download package
uses: actions/download-artifact@v4
Expand All @@ -40,16 +43,21 @@ jobs:
submodules: recursive

- name: Extract package to sample/Plugins
env:
WORKSPACE_PATH: ${{ github.workspace }}
UNREAL_VERSION: ${{ inputs.unreal-version }}
run: |
New-Item -ItemType Directory -Path "${{ github.workspace }}\checkout\sample\Plugins\sentry" -Force
Expand-Archive -Path "sentry-unreal-*-engine${{ inputs.unreal-version }}-github.zip" -DestinationPath "${{ github.workspace }}\checkout\sample\Plugins\sentry" -Force
New-Item -ItemType Directory -Path "$env:WORKSPACE_PATH\checkout\sample\Plugins\sentry" -Force
Expand-Archive -Path "sentry-unreal-*-engine$env:UNREAL_VERSION-github.zip" -DestinationPath "$env:WORKSPACE_PATH\checkout\sample\Plugins\sentry" -Force

- name: Run tests
id: run-tests
env:
EDITOR_BINARY: ${{ inputs.unreal-version == '4.27' && 'UE4Editor.exe' || 'UnrealEditor.exe' }}
run: |
docker exec unreal C:\UnrealEngine\Engine\Build\BatchFiles\RunUAT.bat BuildCookRun `
-project=C:\workspace\checkout\sample\SentryPlayground.uproject `
-archivedirectory=C:\workspace\checkout\sample\Builds `
-project=C:/workspace/checkout/sample/SentryPlayground.uproject `
-archivedirectory=C:/workspace/checkout/sample/Builds `
-platform=Win64 `
-nop4 `
-cook `
Expand All @@ -58,8 +66,8 @@ jobs:
-prereqss `
-package `
-archive
docker exec unreal C:\UnrealEngine\Engine\Binaries\Win64\${{ inputs.unreal-version == '4.27' && 'UE4Editor.exe' || 'UnrealEditor.exe' }} C:\workspace\checkout\sample\SentryPlayground.uproject `
-ReportExportPath=C:\workspace\checkout\sample\Saved\Automation `
docker exec unreal "C:\UnrealEngine\Engine\Binaries\Win64\$env:EDITOR_BINARY" C:/workspace/checkout/sample/SentryPlayground.uproject `
-ReportExportPath=C:/workspace/checkout/sample/Saved/Automation `
-ExecCmds="Automation RunTests Sentry;quit" `
-TestExit="Automation Test Queue Empty" `
-Unattended `
Expand Down
19 changes: 13 additions & 6 deletions .github/workflows/ue-docker-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,17 @@ jobs:
ue4-docker setup

- name: Build Unreal Engine Docker image
env:
UE_REPO: ${{ inputs.ue_repo }}
UE_VERSION: ${{ inputs.ue_version }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
run: |
ue4-docker build custom -repo="${{ inputs.ue_repo }}" -branch="${{ inputs.ue_version }}" \
ue4-docker build custom -repo="$UE_REPO" -branch="$UE_VERSION" \
-basetag ubuntu22.04 \
-suffix "${{ inputs.ue_version }}" \
-username=${{ secrets.DOCKER_USERNAME }} \
-password=${{ secrets.DOCKER_TOKEN }} \
-suffix "$UE_VERSION" \
-username="$DOCKER_USERNAME" \
-password="$DOCKER_TOKEN" \
--linux \
--target minimal \
--exclude debug \
Expand All @@ -102,6 +107,8 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

- name: Tag and push Docker image with pre-built Unreal Engine
env:
UE_VERSION: ${{ inputs.ue_version }}
run: |
docker tag adamrehn/ue4-minimal:custom-${{ inputs.ue_version }} ${{ env.REGISTRY }}/getsentry/unreal-docker:${{ inputs.ue_version }}-linux
docker push ${{ env.REGISTRY }}/getsentry/unreal-docker:${{ inputs.ue_version }}-linux
docker tag "adamrehn/ue4-minimal:custom-$UE_VERSION" "$REGISTRY/getsentry/unreal-docker:$UE_VERSION-linux"
docker push "$REGISTRY/getsentry/unreal-docker:$UE_VERSION-linux"
26 changes: 18 additions & 8 deletions .github/workflows/ue-docker-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ jobs:
- name: Set Visual Studio version based on UE version
id: set_vs_version
shell: bash
env:
UE_VERSION: ${{ inputs.ue_version }}
run: |
if [[ "${{ inputs.ue_version }}" == "4.27" || "${{ inputs.ue_version }}" == "5.0" || "${{ inputs.ue_version }}" == "5.1" ]]; then
if [[ "$UE_VERSION" == "4.27" || "$UE_VERSION" == "5.0" || "$UE_VERSION" == "5.1" ]]; then
echo "vs_version=2019" >> $GITHUB_OUTPUT
else
echo "vs_version=2022" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -82,14 +84,20 @@ jobs:
ue4-docker setup

- name: Build Unreal Engine Docker image
env:
UE_REPO: ${{ inputs.ue_repo }}
UE_VERSION: ${{ inputs.ue_version }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
VS_VERSION: ${{ steps.set_vs_version.outputs.vs_version }}
run: |
ue4-docker build custom -repo="${{ inputs.ue_repo }}" -branch="${{ inputs.ue_version }}" `
ue4-docker build custom -repo="$env:UE_REPO" -branch="$env:UE_VERSION" `
-basetag ltsc2022 `
-suffix "${{ inputs.ue_version }}" `
-suffix "$env:UE_VERSION" `
-isolation=process `
-username=${{ secrets.DOCKER_USERNAME }} `
-password=${{ secrets.DOCKER_TOKEN }} `
--visual-studio ${{ steps.set_vs_version.outputs.vs_version }} `
-username="$env:DOCKER_USERNAME" `
-password="$env:DOCKER_TOKEN" `
--visual-studio "$env:VS_VERSION" `
--target minimal `
--exclude debug `
--exclude templates `
Expand All @@ -104,6 +112,8 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

- name: Tag and push Docker image with pre-built Unreal Engine
env:
UE_VERSION: ${{ inputs.ue_version }}
run: |
docker tag adamrehn/ue4-minimal:custom-${{ inputs.ue_version }} ${{ env.REGISTRY }}/getsentry/unreal-docker:${{ inputs.ue_version }}
docker push ${{ env.REGISTRY }}/getsentry/unreal-docker:${{ inputs.ue_version }}
docker tag "adamrehn/ue4-minimal:custom-$env:UE_VERSION" "$env:REGISTRY/getsentry/unreal-docker:$env:UE_VERSION"
docker push "$env:REGISTRY/getsentry/unreal-docker:$env:UE_VERSION"