-
Couldn't load subscription status.
- Fork 2
misc: auto notify when issue is fixed #152
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
base: main
Are you sure you want to change the base?
Changes from all commits
3a4d517
e733d1f
403c445
ded483f
f608014
1e85352
9bc808b
a60f832
1e5c2b7
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 |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| name: 'Comment on Resolved Issues' | ||
| description: 'Comments on issues referenced in PRs merged since last release' | ||
|
|
||
| inputs: | ||
| token: | ||
| description: > | ||
| Personal access token (PAT) used to fetch the repository. The PAT is configured | ||
| with the local git config, which enables your scripts to run authenticated git | ||
| commands. The post-job step removes the PAT. | ||
| default: ${{ github.token }} | ||
| required: false | ||
xinsong-cui marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Comment on issues | ||
| shell: bash | ||
| env: | ||
| GH_TOKEN: ${{ inputs.token }} | ||
| run: | | ||
| # Get the previous tag | ||
| PREVIOUS_TAG=$(git tag --sort=-version:refname | sed -n '2p') | ||
| CURRENT_TAG=$(git tag --sort=-version:refname | sed -n '1p') | ||
|
|
||
| # Convert tag date to GitHub search format | ||
| TAG_DATE=$(git log -1 --format="%ci" "$PREVIOUS_TAG" | sed 's/ /T/' | sed 's/ +0000/Z/') | ||
| echo "Using tag date: $TAG_DATE" | ||
|
|
||
| # Find all PRs merged from the last release tag date | ||
| ALL_PRS=$(gh pr list \ | ||
| --state merged \ | ||
| --json number,body,mergedAt \ | ||
| --jq '[.[] | select(.mergedAt > "'$TAG_DATE'") | .number]' | ||
| ) | ||
|
|
||
| # Find all issue number from PRs merged into release branch | ||
| ISSUE_NUMBERS="" | ||
| FAILURES="" | ||
|
|
||
| for pr_number in $(echo "$ALL_PRS" | jq -r '.[]'); do | ||
|
|
||
| # Get the merge commit SHA for this PR | ||
| MERGE_COMMIT=$(gh pr view "$pr_number" --json mergeCommit --jq '.mergeCommit.oid') | ||
|
|
||
| # Check if this commit exists in the release branch | ||
| if git merge-base --is-ancestor "$MERGE_COMMIT" origin/release 2>/dev/null; then | ||
| echo "PR $pr_number is in release branch" | ||
|
|
||
| # Get issue numbers from changelog entries in this PR | ||
| PR_ISSUES=$(gh pr view "$pr_number" --json files --jq '.files[].path' | \ | ||
| grep '\.changes/.*\.json$' | \ | ||
| xargs -I {} cat {} 2>/dev/null | \ | ||
| jq -r '.issues[]?' 2>/dev/null | \ | ||
| sed 's/.*#//') | ||
| echo " Found issues: $PR_ISSUES" | ||
|
|
||
| # Comment on each issue | ||
| for issue in $PR_ISSUES; do | ||
| if [ -n "$issue" ]; then | ||
| echo "Commenting on issue #$issue" | ||
| if ! gh issue comment "$issue" --body "A [change](https://github.com/${{ github.repository }}/pull/$pr_number) related to this issue was included in [**$CURRENT_TAG**](https://github.com/${{ github.repository }}/releases/tag/$CURRENT_TAG)."; then | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm seeing a test that looks like this:
(no "change"). It looks correct here, so I just want to confirm you fixed it after that test ran? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, thats being fix |
||
| echo "::error::Failed to comment on issue #$issue" | ||
| FAILURES="$FAILURES #$issue" | ||
| fi | ||
| fi | ||
| done | ||
| fi | ||
| done | ||
|
|
||
| if [ -n "$FAILURES" ]; then | ||
| echo "::error::Failed to update the following issue(s):$FAILURES" | ||
| exit 1 | ||
| fi | ||
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.
Rather than checking the PR body for GitHub issue links, I was hoping we could be more intentional with these comments by using changelog entries. I think the current implementation will be much noisier than it needs to be