-
Notifications
You must be signed in to change notification settings - Fork 3
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
Fix race condition when publishing images #848
Merged
Merged
Conversation
This file contains 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
lorenyu
commented
Jan 22, 2025
echo "Commit hash: $COMMIT_HASH" | ||
echo "commit_hash=$COMMIT_HASH" >> "$GITHUB_OUTPUT" | ||
build-and-publish: | ||
name: Build and publish | ||
runs-on: ubuntu-latest | ||
needs: get-commit-hash | ||
concurrency: ${{ github.workflow }}-${{ needs.get-commit-hash.outputs.commit_hash }} | ||
concurrency: ${{ github.workflow }}-${{ inputs.app_name }}-${{ needs.get-commit-hash.outputs.commit_hash }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add app_name to the concurrency group so that multiple apps can build at the same time
doshitan
approved these changes
Jan 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think comment can be cleaned up, otherwise looks good.
doshitan
reviewed
Jan 22, 2025
This was referenced Jan 22, 2025
lorenyu
added a commit
that referenced
this pull request
Jan 22, 2025
Previous fix #848 didn't quite fix the race condition (see https://github.com/navapbc/platform-test/actions/runs/12917748724/attempts/1). I think it’s because the github.workflow in the concurrency group refers to the parent workflow, which is different, so cd-app.yml and ci-app-infra-service.yml both calling build-and-publish.yml workflow would produce different concurrency groups.
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.
Ticket
Resolves #836
Changes
The
ci-{{app_name}}-infra-service.yml
andcd-{{app_name}}.yml
workflowsoccasionally run into issues trying to publish an already existing image tag[1],
failing with something like:
I believe what's happening is that for merges to
main
, the two workflows getkicked off at the same time, both needing build and publish an image for the
same commit and using different methods for doing that building/publishing.
ci-{{app_name}}-infra-service.yml
runs the commands internally to its testlogic,
cd-{{app_name}}.yml
uses thebuild-and-publish.yml
workflow.By having
ci-{{app_name}}-infra-service.yml
use the re-usablebuild-and-publish workflow that
cd-{{app_name}}.yml
is using, which has aninternal concurrency limit, the workflows should no longer race against each
other to build the same commit.
[1] https://github.com/navapbc/platform-test-nextjs/actions/runs/12484891877/job/34842946860
Testing
see navapbc/platform-test#146