File tree Expand file tree Collapse file tree 2 files changed +43
-18
lines changed Expand file tree Collapse file tree 2 files changed +43
-18
lines changed Original file line number Diff line number Diff line change
1
+ name : Post pull-request comment
2
+ on :
3
+ workflow_run :
4
+ workflows : ["Query help preview"]
5
+ types :
6
+ - completed
7
+
8
+ permissions :
9
+ pull-requests : write
10
+
11
+ jobs :
12
+ post_comment :
13
+ runs-on : ubuntu-latest
14
+ steps :
15
+ - name : Download artifact
16
+ uses : dawidd6/action-download-artifact@af92a8455a59214b7b932932f2662fdefbd78126
17
+ with :
18
+ workflow : ${{ github.event.workflow_run.workflow_id }}
19
+ workflow_conclusion : success
20
+ name : comment
21
+ - run : |
22
+ PR=$(grep -o '^[0-9]\+$' pr.txt)
23
+ PR_HEAD_SHA=$(gh api "/repos/${{ github.repository }}/pulls/${PR}" --jq .head.sha)
24
+ # Check that the pull-request head SHA matches the head SHA of the workflow run
25
+ if [ "${WORKFLOW_RUN_HEAD_SHA}" != "${PR_HEAD_SHA}" ]; then
26
+ exit 1
27
+ fi
28
+ cat comment.txt | gh pr comment "${PR}" --repo "${{ github.repository }}" -F -
29
+ env:
30
+ GITHUB_TOKEN: ${{ github.token }}
31
+ WORKFLOW_RUN_HEAD_SHA: ${{ github.event.workflow_run.head_commit.id }}
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ permissions:
4
4
contents : read
5
5
6
6
on :
7
- pull_request_target :
7
+ pull_request :
8
8
branches :
9
9
- main
10
10
- " rc/*"
@@ -17,10 +17,16 @@ jobs:
17
17
contents : read
18
18
runs-on : ubuntu-latest
19
19
steps :
20
+ - run : echo "${{ github.event.number }}" > pr.txt
21
+ - uses : actions/upload-artifact@v2
22
+ with :
23
+ name : comment
24
+ path : pr.txt
25
+ retention-days : 1
26
+
20
27
- uses : github/codeql/.github/actions/fetch-codeql@main
21
28
- uses : actions/checkout@v2
22
29
with :
23
- ref : refs/pull/${{ github.event.number }}/merge
24
30
fetch-depth : 2
25
31
persist-credentials : false
26
32
33
39
34
40
- name : QHelp preview
35
41
run : |
42
+ echo "QHelp previews:" > comment.txt
36
43
cat "${{ runner.temp }}/paths.txt" | while read path; do
37
44
if [ ! -f "${path}" ]; then
38
45
exit 1
@@ -41,23 +48,10 @@ jobs:
41
48
echo
42
49
codeql generate query-help --format=markdown -- "./${path}"
43
50
echo "</details>"
44
- done > comment.txt
51
+ done >> comment.txt
45
52
46
53
- uses : actions/upload-artifact@v2
47
54
with :
48
- name : comment.txt
55
+ name : comment
49
56
path : comment.txt
50
-
51
- post_comment :
52
- permissions :
53
- pull-requests : write
54
- runs-on : ubuntu-latest
55
- needs : qhelp
56
- steps :
57
- - uses : actions/download-artifact@v2
58
- with :
59
- name : comment.txt
60
- - run : |
61
- (echo "QHelp previews:"; cat comment.txt) | gh pr comment "${{ github.event.pull_request.number }}" --repo "${{ github.repository }}" -F -
62
- env:
63
- GITHUB_TOKEN: ${{ github.token }}
57
+ retention-days : 1
You can’t perform that action at this time.
0 commit comments