Skip to content

Commit f654f66

Browse files
committed
test
1 parent cdfb435 commit f654f66

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

.github/workflows/test.yml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,27 @@ jobs:
2626
git-token: ${{ github.ref_name == 'main' && secrets.GITHUB_TOKEN || '' }}
2727

2828
# Post coverage report as comment
29-
- name: find coverage report comment
30-
uses: peter-evans/find-comment@v3
31-
id: fc
32-
with:
33-
issue-number: ${{ github.event.pull_request.number }}
34-
comment-author: 'github-actions[bot]'
35-
body-includes: 'Total test coverage:'
29+
- name: get pull request ID
30+
id: get_pr_id
31+
run: |
32+
# Make an API call to find the pull request associated with this branch
33+
PR_DATA=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
34+
"https://api.github.com/repos/${{ github.repository }}/pulls?head=${{ github.repository_owner }}:${{ github.ref_name }}&state=open")
35+
36+
# Parse the PR ID if a pull request is found
37+
PR_ID=$(echo "$PR_DATA" | jq -r '.[0].number')
38+
39+
# Output the PR ID if it exists
40+
if [ "$PR_ID" != "null" ]; then
41+
echo "pull_request_id=$PR_ID" >> $GITHUB_ENV
42+
else
43+
echo "No open pull request found for this branch."
44+
fi
3645
- name: post coverage report
3746
uses: peter-evans/create-or-update-comment@v4
3847
with:
3948
token: ${{ secrets.GITHUB_TOKEN }}
40-
issue-number: ${{ github.event.pull_request.number }}
49+
issue-number: ${{ env.pull_request_id }}
4150
comment-id: ${{ steps.fc.outputs.comment-id }}
4251
body: ${{ fromJSON(steps.coverage.outputs.report) }}
4352
edit-mode: replace

0 commit comments

Comments
 (0)