Skip to content

Commit 78b4a17

Browse files
committed
Move PR comment creation to separate workflow on:pull_request_target
1 parent 20acd31 commit 78b4a17

File tree

2 files changed

+69
-18
lines changed

2 files changed

+69
-18
lines changed

.github/workflows/integration-tests.yml

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ jobs:
144144
done
145145
echo "Processed $conv TRX file(s)"
146146
147-
148147
- name: Publish Test Report
149148
if: always()
150149
uses: ctrf-io/github-test-reporter@v1
@@ -186,24 +185,18 @@ jobs:
186185
env:
187186
GITHUB_TOKEN: ${{ github.token }}
188187

188+
- name: Save PR Number
189+
run: echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV
189190

190-
- name: Create PR Comment
191-
if: always()
192-
uses: ctrf-io/github-test-reporter@v1
193-
with:
194-
report-path: 'ctrf/**/*.json'
195-
196-
summary: true
197-
pull-request: true
198-
use-suite-name: true
199-
update-comment: true
200-
always-group-by: true
201-
overwrite-comment: true
202-
upload-artifact: false
191+
- name: Upload PR Number as Artifact
192+
run: echo $PR_NUMBER > pr_number.txt
193+
shell: bash
203194

204-
pull-request-report: true
205-
env:
206-
GITHUB_TOKEN: ${{ github.token }}
195+
- name: Upload PR Number Artifact
196+
uses: actions/upload-artifact@v4
197+
with:
198+
name: pr_number
199+
path: pr_number.txt
207200

208201
- name: Summary
209-
run: echo "All matrix test jobs completed."
202+
run: echo "All matrix test jobs completed."

.github/workflows/pr-comment.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Create PR Comments
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Tests"]
6+
types: [completed]
7+
8+
permissions:
9+
contents: read
10+
actions: read
11+
pull-requests: write
12+
13+
jobs:
14+
pr-comment:
15+
name: Post Test Result as PR comment
16+
runs-on: ubuntu-24.04
17+
18+
steps:
19+
- name: Download PR number artifact
20+
uses: dawidd6/action-download-artifact@v8
21+
with:
22+
github_token: ${{ github.token }}
23+
run_id: ${{ github.event.workflow_run.id }}
24+
name: pr-number
25+
path: pr-number
26+
27+
- name: Read PR Number
28+
id: read_pr_number
29+
run: |
30+
PR_NUMBER=$(cat pr_number/pr_number.txt)
31+
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
32+
33+
- name: Download CTRF artifact
34+
uses: dawidd6/action-download-artifact@v8
35+
with:
36+
github_token: ${{ github.token }}
37+
run_id: ${{ github.event.workflow_run.id }}
38+
name: ctrf-report
39+
path: ctrf
40+
41+
- name: Post PR Comment
42+
if: always()
43+
uses: ctrf-io/github-test-reporter@v1
44+
with:
45+
report-path: 'ctrf/**/*.json'
46+
issue: ${{ env.PR_NUMBER }}
47+
48+
summary: true
49+
pull-request: true
50+
use-suite-name: true
51+
update-comment: true
52+
always-group-by: true
53+
overwrite-comment: true
54+
upload-artifact: false
55+
56+
pull-request-report: true
57+
env:
58+
GITHUB_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)