Skip to content

Commit 0ff1886

Browse files
committed
fix
1 parent e5ebae1 commit 0ff1886

File tree

1 file changed

+44
-51
lines changed

1 file changed

+44
-51
lines changed

.github/workflows/test.yml

Lines changed: 44 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -20,54 +20,47 @@ jobs:
2020
- name: Comment on PRs with issue numbers
2121
env:
2222
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23-
runs:
24-
using: composite
25-
steps:
26-
- name: Comment on issues
27-
shell: bash
28-
env:
29-
GH_TOKEN: ${{ inputs.token }}
30-
run: |
31-
# Get the previous tag
32-
PREVIOUS_TAG=$(git tag --sort=-version:refname | sed -n '2p')
33-
CURRENT_TAG=$(git tag --sort=-version:refname | sed -n '1p')
34-
35-
# Convert tag date to GitHub search format
36-
TAG_DATE=$(git log -1 --format="%ci" "$PREVIOUS_TAG" | sed 's/ /T/' | sed 's/ +0000/Z/')
37-
echo "Using tag date: $TAG_DATE"
38-
39-
# Find all PRs merged from the last release tag date
40-
ALL_PRS=$(gh pr list \
41-
--state open \
42-
--json number,body,createdAt \
43-
--jq '[.[] | select(.createdAt > "$TAG_DATE") | .number]'
44-
)
45-
46-
# Find all issue number from PRs merged into release branch
47-
ISSUE_NUMBERS=""
48-
for pr_number in $(echo "$ALL_PRS" | jq -r '.[]'); do
49-
50-
# Get the merge commit SHA for this PR
51-
MERGE_COMMIT=$(gh pr view "$pr_number" --json mergeCommit --jq '.mergeCommit.oid')
52-
53-
# Check if this commit exists in the release branch
54-
if git merge-base --is-ancestor "$MERGE_COMMIT" origin/release 2>/dev/null; then
55-
echo "PR $pr_number is in release branch"
56-
57-
# Get issue numbers from this PR
58-
PR_ISSUES=$(gh pr view "$pr_number" --json body --jq '.body' | \
59-
grep -o 'issues/[0-9]*' | \
60-
sed 's/issues\///')
61-
echo " Found issues: $PR_ISSUES"
62-
63-
ISSUE_NUMBERS="$ISSUE_NUMBERS $PR_ISSUES"
64-
fi
65-
done
66-
67-
# Comment on each issue found
68-
echo "$ISSUE_NUMBERS" | tr ' ' '\n' | while read -r issue_number; do
69-
if [ -n "$issue_number" ]; then
70-
echo "Commenting on issue #$issue_number"
71-
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"
72-
fi
73-
done
23+
run: |
24+
# Get the previous tag
25+
PREVIOUS_TAG=$(git tag --sort=-version:refname | sed -n '2p')
26+
CURRENT_TAG=$(git tag --sort=-version:refname | sed -n '1p')
27+
28+
# Convert tag date to GitHub search format
29+
TAG_DATE=$(git log -1 --format="%ci" "$PREVIOUS_TAG" | sed 's/ /T/' | sed 's/ +0000/Z/')
30+
echo "Using tag date: $TAG_DATE"
31+
32+
# Find all PRs merged from the last release tag date
33+
ALL_PRS=$(gh pr list \
34+
--state open \
35+
--json number,body,createdAt \
36+
--jq '[.[] | select(.createdAt > "$TAG_DATE") | .number]'
37+
)
38+
39+
# Find all issue number from PRs merged into release branch
40+
ISSUE_NUMBERS=""
41+
for pr_number in $(echo "$ALL_PRS" | jq -r '.[]'); do
42+
43+
# Get the merge commit SHA for this PR
44+
MERGE_COMMIT=$(gh pr view "$pr_number" --json mergeCommit --jq '.mergeCommit.oid')
45+
46+
# Check if this commit exists in the release branch
47+
if git merge-base --is-ancestor "$MERGE_COMMIT" origin/release 2>/dev/null; then
48+
echo "PR $pr_number is in release branch"
49+
50+
# Get issue numbers from this PR
51+
PR_ISSUES=$(gh pr view "$pr_number" --json body --jq '.body' | \
52+
grep -o 'issues/[0-9]*' | \
53+
sed 's/issues\///')
54+
echo " Found issues: $PR_ISSUES"
55+
56+
ISSUE_NUMBERS="$ISSUE_NUMBERS $PR_ISSUES"
57+
fi
58+
done
59+
60+
# Comment on each issue found
61+
echo "$ISSUE_NUMBERS" | tr ' ' '\n' | while read -r issue_number; do
62+
if [ -n "$issue_number" ]; then
63+
echo "Commenting on issue #$issue_number"
64+
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"
65+
fi
66+
done

0 commit comments

Comments
 (0)