Skip to content

Commit f1aac2b

Browse files
committed
improvements
1 parent 1202d22 commit f1aac2b

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

.github/workflows/test.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,37 +27,34 @@ jobs:
2727
git-token: ${{ github.ref_name == 'main' && secrets.GITHUB_TOKEN || '' }}
2828

2929
# Post coverage report as comment
30-
- name: get pull request ID
31-
id: get_pr_id
30+
- name: find pull request ID
31+
if: github.event_name == 'pull_request'
3232
run: |
33-
# Make an API call to find the pull request associated with this branch
3433
PR_DATA=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
3534
"https://api.github.com/repos/${{ github.repository }}/pulls?head=${{ github.repository_owner }}:${{ github.ref_name }}&state=open")
36-
37-
# Parse the PR ID if a pull request is found
3835
PR_ID=$(echo "$PR_DATA" | jq -r '.[0].number')
39-
40-
# Output the PR ID if it exists
36+
4137
if [ "$PR_ID" != "null" ]; then
4238
echo "pull_request_id=$PR_ID" >> $GITHUB_ENV
4339
else
4440
echo "No open pull request found for this branch."
4541
fi
4642
- name: find if coverage report is already present
43+
if: github.event_name == 'pull_request'
4744
uses: peter-evans/find-comment@v3
4845
id: fc
4946
with:
5047
issue-number: ${{ env.pull_request_id }}
5148
comment-author: 'github-actions[bot]'
5249
body-includes: 'Total test coverage: '
5350
- name: post coverage report
51+
if: github.event_name == 'pull_request'
5452
uses: peter-evans/create-or-update-comment@v4
5553
with:
5654
token: ${{ secrets.GITHUB_TOKEN }}
5755
issue-number: ${{ env.pull_request_id }}
5856
comment-id: ${{ steps.fc.outputs.comment-id }}
5957
body: |
6058
```
61-
${{ fromJSON(steps.coverage.outputs.report) }}
62-
```
59+
${{ fromJSON(steps.coverage.outputs.report) }}```
6360
edit-mode: replace

0 commit comments

Comments
 (0)