Skip to content

Commit e5ebae1

Browse files
committed
update test
1 parent dd6944f commit e5ebae1

File tree

1 file changed

+50
-17
lines changed

1 file changed

+50
-17
lines changed

.github/workflows/test.yml

Lines changed: 50 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,54 @@ jobs:
2020
- name: Comment on PRs with issue numbers
2121
env:
2222
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23-
run: |
24-
PREVIOUS_TAG=$(git describe --tags --abbrev=0)
25-
TAG_DATE=$(git log -1 --format="%ci" "$PREVIOUS_TAG" | sed 's/ /T/' | sed 's/ +0000/Z/')
26-
echo "Using tag date: $TAG_DATE"
27-
28-
ISSUE_NUMBERS=$(gh pr list \
29-
--json number,body,createdAt \
30-
--jq $'.[] | select(.createdAt > "'$TAG_DATE'") | .body' | \
31-
grep -o 'issues/[0-9]*' | \
32-
sed 's/issues\///'
33-
)
34-
35-
echo "Found issues: $ISSUE_NUMBERS"
36-
37-
for issue_number in $ISSUE_NUMBERS; do
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
3870
echo "Commenting on issue #$issue_number"
39-
gh issue comment "$issue_number" --body "This issue was resolved and included in the latest release."
40-
done
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

0 commit comments

Comments
 (0)