-
Notifications
You must be signed in to change notification settings - Fork 1
fix(sync-actions): create tag when no changes; tag merge commit when PR merges #19
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -329,10 +329,19 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Create tag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if: steps.resolve-ref.outputs.should_create_tag == 'true' && steps.create-pr.outputs.changed == 'true' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if: steps.resolve-ref.outputs.should_create_tag == 'true' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "::group::Creating Tag" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cd gh-aw-actions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # When a PR was created and merged, we need to pull the merge commit from main | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # because the working directory is still on the sync branch. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [[ "${{ steps.create-pr.outputs.changed }}" == "true" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Check noticeCode scanning / zizmor code injection via template expansion Note
code injection via template expansion
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "PR was merged — fetching main to tag the merge commit..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| git fetch origin main | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| git checkout -B main origin/main | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+337
to
+342
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # When a PR was created and merged, we need to pull the merge commit from main | |
| # because the working directory is still on the sync branch. | |
| if [[ "${{ steps.create-pr.outputs.changed }}" == "true" ]]; then | |
| echo "PR was merged — fetching main to tag the merge commit..." | |
| git fetch origin main | |
| git checkout -B main origin/main | |
| # When a PR was created and merged, we need to tag the merge commit for that PR | |
| # rather than whatever commit happens to be at the tip of main when this step runs. | |
| if [[ "${{ steps.create-pr.outputs.changed }}" == "true" ]]; then | |
| echo "PR was merged — resolving merge commit SHA to tag..." | |
| PR_NUMBER="${{ steps.create-pr.outputs.pr_number }}" | |
| if [[ -z "$PR_NUMBER" ]]; then | |
| echo "Error: PR number not available; cannot determine merge commit to tag." >&2 | |
| exit 1 | |
| fi | |
| # Ensure gh is authenticated. Prefer an existing GH_TOKEN/GITHUB_TOKEN if set. | |
| if [[ -z "${GH_TOKEN:-}" && -n "${GITHUB_TOKEN:-}" ]]; then | |
| export GH_TOKEN="$GITHUB_TOKEN" | |
| fi | |
| MERGE_COMMIT_SHA="$(gh pr view "$PR_NUMBER" --json mergeCommit --jq '.mergeCommit.oid')" | |
| if [[ -z "$MERGE_COMMIT_SHA" || "$MERGE_COMMIT_SHA" == "null" ]]; then | |
| echo "Error: Could not determine merge commit SHA for PR #$PR_NUMBER." >&2 | |
| exit 1 | |
| fi | |
| echo "Fetching and checking out merge commit $MERGE_COMMIT_SHA for PR #$PR_NUMBER..." | |
| git fetch origin | |
| git checkout "$MERGE_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.
The
Create tagstep now runs whenevershould_create_tag == 'true', even whensteps.create-pr.outputs.changedis false. Since the script force-deletes and re-creates the annotated tag, re-running the workflow with no file changes will still rewrite the tag object (and may trigger downstream automation). Consider either restoring thechanged == 'true'guard, or making tag creation idempotent by skipping delete/recreate when the existing tag already points to the intended commit.