Guard Build job JSON parsing#2260
Open
kiwigitops wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a GitHub Actions workflow failure where the Build job’s if: condition attempted to fromJson() an empty needs.Initialization.outputs.buildOrderJson, causing CI/CD to error and skip Build.
Changes:
- Guarded the Build job
if:condition in both template CI/CD workflows to ensurebuildOrderJsonis non-empty before callingfromJson(...). - Applied the same guard to the
if:conditions generated for multi-depth Build jobs inModifyBuildWorkflows.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| Templates/Per Tenant Extension/.github/workflows/CICD.yaml | Adds a non-empty buildOrderJson guard before fromJson(...) in the Build job condition. |
| Templates/AppSource App/.github/workflows/CICD.yaml | Adds the same non-empty buildOrderJson guard before fromJson(...) in the Build job condition. |
| Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1 | Updates multi-depth Build job condition generation to include the same guard. |
| if: (!failure()) && (!cancelled()) && needs.Initialization.outputs.buildOrderJson != '' && fromJson(needs.Initialization.outputs.buildOrderJson)[0].projectsCount > 0 | ||
| strategy: | ||
| matrix: | ||
| include: ${{ fromJson(needs.Initialization.outputs.buildOrderJson)[0].buildDimensions }} |
| if: (!failure()) && (!cancelled()) && needs.Initialization.outputs.buildOrderJson != '' && fromJson(needs.Initialization.outputs.buildOrderJson)[0].projectsCount > 0 | ||
| strategy: | ||
| matrix: | ||
| include: ${{ fromJson(needs.Initialization.outputs.buildOrderJson)[0].buildDimensions }} |
Comment on lines
+189
to
+201
| # Example (depth 1): | ||
| # needs: [ Initialization ] | ||
| # if: (!failure()) && (!cancelled()) && fromJson(needs.Initialization.outputs.buildOrderJson)[0].projectsCount > 0 | ||
| $if = "if: (!failure()) && (!cancelled()) && fromJson(needs.Initialization.outputs.buildOrderJson)[$index].projectsCount > 0" | ||
| # if: (!failure()) && (!cancelled()) && needs.Initialization.outputs.buildOrderJson != '' && fromJson(needs.Initialization.outputs.buildOrderJson)[0].projectsCount > 0 | ||
| $if = "if: (!failure()) && (!cancelled()) && needs.Initialization.outputs.buildOrderJson != '' && fromJson(needs.Initialization.outputs.buildOrderJson)[$index].projectsCount > 0" | ||
| } | ||
| else { | ||
| # Subsequent build jobs needs to have a dependency on all previous build jobs | ||
| # Example (depth 2): | ||
| # needs: [ Initialization, Build1 ] | ||
| # if: (!failure()) && (!cancelled()) && (needs.Build1.result == 'success' || needs.Build1.result == 'skipped') && fromJson(needs.Initialization.outputs.buildOrderJson)[0].projectsCount > 0 | ||
| # if: (!failure()) && (!cancelled()) && (needs.Build1.result == 'success' || needs.Build1.result == 'skipped') && needs.Initialization.outputs.buildOrderJson != '' && fromJson(needs.Initialization.outputs.buildOrderJson)[0].projectsCount > 0 | ||
| # Another example (depth 3): | ||
| # needs: [ Initialization, Build2, Build1 ] | ||
| # if: (!failure()) && (!cancelled()) && (needs.Build2.result == 'success' || needs.Build2.result == 'skipped') && (needs.Build1.result == 'success' || needs.Build1.result == 'skipped') && fromJson(needs.Initialization.outputs.buildOrderJson)[0].projectsCount > 0 | ||
| # if: (!failure()) && (!cancelled()) && (needs.Build2.result == 'success' || needs.Build2.result == 'skipped') && (needs.Build1.result == 'success' || needs.Build1.result == 'skipped') && needs.Initialization.outputs.buildOrderJson != '' && fromJson(needs.Initialization.outputs.buildOrderJson)[0].projectsCount > 0 |
3972fd2 to
1283d72
Compare
Author
|
Updated the other template Build conditions with the same guard and fixed the generated workflow examples to use the matching build-order index. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
needs.Initialization.outputs.buildOrderJsonCloses #2258.
Testing
git diff --check