Skip to content

Commit

Permalink
Added conditionals to "build_" GHA workflows so that they only run wh…
Browse files Browse the repository at this point in the history
…en needed
  • Loading branch information
PedroRauizBeamable committed Jul 9, 2024
1 parent 492ae23 commit 8bd6ad1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/build_linux_client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,19 @@ jobs:
build:
needs: changes
uses: ./.github/workflows/build_linux.yml
uses: ./.github/workflows/build_linux.yml

# Only run this if the changes job actually detected changes OR if we are building all.
# Empty array will be serialized as [] so you can simply check it in the if condition.
# Second part of the condition just checks if it's not an empty string - that would mean some failure during changes job execution.
if: ${{ (!inputs.buildAll && needs.changes.outputs.BEAMPROJS != '[]' && needs.changes.outputs.BEAMPROJS != '') || inputs.buildAll }}

strategy:
max-parallel: 1
matrix:
# Result of changes job as well as vars are plain strings. That's why you have to use fromJson() to parse it into array.
# The list of BeamProj is defined by "wherever we detected changes" when inputs.buildAll is false
# The list of BeamProj is a hard-coded list of all BeamProjs when inputs.buildAll is true
# This is because our RC job also reuses this but needs to generate ALL builds independent of changes.
# The list of BeamProj is Repository Variable (declared in Github's UnrealSDK's Settings -> Secrets & Variables -> Variables).
beamProj: ${{ !inputs.buildAll && fromJSON(needs.changes.outputs.BEAMPROJS) || fromJSON(vars.ALL_BEAMPROJS) }}
with:
beamProj: ${{ matrix.beamProj }}
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/build_linux_server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,17 @@ jobs:
build:
needs: changes
uses: ./.github/workflows/build_linux.yml
uses: ./.github/workflows/build_linux.yml

# Only run this if the changes job actually detected changes OR if we are building all.
# Empty array will be serialized as [] so you can simply check it in the if condition.
# Second part of the condition just checks if it's not an empty string - that would mean some failure during changes job execution.
if: ${{ (!inputs.buildAll && needs.changes.outputs.BEAMPROJS != '[]' && needs.changes.outputs.BEAMPROJS != '') || inputs.buildAll }}

strategy:
max-parallel: 1
matrix:
# Result of changes job as well as vars are plain strings. That's why you have to use fromJson() to parse it into array.
# The list of BeamProj is defined by "wherever we detected changes" when inputs.buildAll is false
# The list of BeamProj is Repository Variable (declared in Github's UnrealSDK's Settings -> Secrets & Variables -> Variables).
beamProj: ${{ !inputs.buildAll && fromJSON(needs.changes.outputs.BEAMPROJS) || fromJSON(vars.ALL_SERVER_BEAMPROJS) }}
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/build_windows_client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,18 @@ jobs:
build:
uses: ./.github/workflows/build_windows.yml

# Only run this if the changes job actually detected changes OR if we are building all.
# Empty array will be serialized as [] so you can simply check it in the if condition.
# Second part of the condition just checks if it's not an empty string - that would mean some failure during changes job execution.
if: ${{ (!inputs.buildAll && needs.changes.outputs.BEAMPROJS != '[]' && needs.changes.outputs.BEAMPROJS != '') || inputs.buildAll }}

strategy:
max-parallel: 2
matrix:
# Result of changes job as well as vars are plain strings. That's why you have to use fromJson() to parse it into array.
# The list of BeamProj is defined by "wherever we detected changes" when inputs.buildAll is false
# The list of BeamProj is a hard-coded list of all BeamProjs when inputs.buildAll is true
# This is because our RC job also reuses this but needs to generate ALL builds independent of changes.
# The list of BeamProj is Repository Variable (declared in Github's UnrealSDK's Settings -> Secrets & Variables -> Variables).
beamProj: ${{ !inputs.buildAll && fromJSON(needs.changes.outputs.BEAMPROJS) || fromJSON(vars.ALL_BEAMPROJS) }}
with:
beamProj: ${{ matrix.beamProj }}
Expand Down

0 comments on commit 8bd6ad1

Please sign in to comment.