Skip to content

Commit 403c445

Browse files
committed
feedback
1 parent e733d1f commit 403c445

File tree

1 file changed

+32
-10
lines changed

1 file changed

+32
-10
lines changed

.github/actions/comment-resolved-issues/action.yml

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,38 @@ runs:
2626
TAG_DATE=$(git log -1 --format="%ci" "$PREVIOUS_TAG" | sed 's/ /T/' | sed 's/ +0000/Z/')
2727
echo "Using tag date: $TAG_DATE"
2828
29-
# Find issue numbers from PRs created from the last release tag date
30-
ISSUE_NUMBERS=$(gh pr list \
31-
--json number,body,createdAt \
32-
--jq '.[] | select(.createdAt > "'$TAG_DATE'") | .body' | \
33-
grep -o 'issues/[0-9]*' | \
34-
sed 's/issues\///'
29+
# Find all PRs merged from the last release tag date
30+
ALL_PRS=$(gh pr list \
31+
--state merged \
32+
--json number,body,mergedAt \
33+
--jq '[.[] | select(.mergedAt > "$TAG_DATE") | .number]'
3534
)
3635
37-
# Comment on each issue found
38-
for issue_number in $ISSUE_NUMBERS; do
39-
echo "Commenting on issue #$issue_number"
40-
gh issue comment "$issue_number" --body "A change related to this issue was included in release: $CURRENT_TAG" || echo "Failed to comment on #$issue_number"
36+
# Find all issue number from PRs merged from the last release tag date
37+
ISSUE_NUMBERS=""
38+
for pr_number in $(echo "$ALL_PRS" | jq -r '.[]'); do
39+
40+
# Get the merge commit SHA for this PR
41+
MERGE_COMMIT=$(gh pr view "$pr_number" --json mergeCommit --jq '.mergeCommit.oid')
42+
43+
# Check if this commit exists in the release branch
44+
if git merge-base --is-ancestor "$MERGE_COMMIT" origin/release 2>/dev/null; then
45+
echo "PR $pr_number is in release branch"
46+
47+
# Get issue numbers from this PR
48+
PR_ISSUES=$(gh pr view "$pr_number" --json body --jq '.body' | \
49+
grep -o 'issues/[0-9]*' | \
50+
sed 's/issues\///')
51+
echo " Found issues: $PR_ISSUES"
52+
53+
ISSUE_NUMBERS="$ISSUE_NUMBERS $PR_ISSUES"
54+
fi
4155
done
56+
57+
# Comment on each issue found
58+
echo "$ISSUE_NUMBERS" | tr ' ' '\n' | while read -r issue_number; do
59+
if [ -n "$issue_number" ]; then
60+
echo "Commenting on issue #$issue_number"
61+
gh issue comment "$issue_number" --body "A change related to this issue was included in release: $CURRENT_TAG" || echo "::error Failed to comment on #$issue_number"
62+
fi
63+
done

0 commit comments

Comments
 (0)