-
Notifications
You must be signed in to change notification settings - Fork 4
Dispatch release workflow from CI workflow #218
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
Conversation
| TAG_SHA="$(git rev-parse "$REF^{commit}")" | ||
| COMMIT_SHA="${{ github.event.workflow_run.head_sha }}" | ||
| if [ "$TAG_SHA" != "$COMMIT_SHA" ]; then | ||
| echo "Tag SHA $TAG_SHA does not match pushed commit SHA $COMMIT_SHA" |
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 tested (in another repository) that this successfully guards against the following case:
- A branch with the same name as an existing valid tag is created
- The "CI" workflow in that branch is modified to run upon a push to the branch (thus causing the CI workflow to be triggered on pushes to the branch)
| name: Publish Client | ||
| needs: validate-tag | ||
| runs-on: ubuntu-latest | ||
| if: ${{ needs.validate-tag.outputs.valid_tag == 'true' && github.event.workflow_run.conclusion == 'success' }} |
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.
dallasread
left a comment
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.
This looks good to me – thanks! 🥇




This updates our workflows to dispatch
Releasefrom theCIworkflow.Currently the
Releaseworkflow is directly triggered upon a tag push but as discussed here, it relies on a third-party action to validate that the CI workflow ran successfully for the tagged commit.With the changes in this PR, we will use
workflow_runto make theReleaseworkflow run automatically when theCIworkflow completes, with the following necessary accompanying changes:CIworkflow upon a tag push that matches a valid patternvalidate-tagjob to theReleaseworkflow, that validates that theCIworkflow was triggered from a push of a valid tag, and only allows thepublishjob to run if the validation succeeds. This is necessary because theCIworkflow can be triggered by other conditions including a push tomainbranch.Addresses #201
Note: Here is a simplified version of the workflows for ease of testing in any repository: https://gist.github.com/lokst/e8ee94f6289bbc82a25b21c96e44bf2f