|
1 | 1 | name: New Authors Check |
2 | 2 |
|
| 3 | +# pull_request_target runs with base-repo permissions (including write) even |
| 4 | +# for fork PRs, allowing us to post a comment directly without the artifact |
| 5 | +# hand-off to a second workflow_run workflow. |
| 6 | +# |
| 7 | +# Only git history is read here — no PR code is built or executed — so |
| 8 | +# checking out the PR head SHA is safe under pull_request_target. |
3 | 9 | on: |
4 | | - pull_request: |
| 10 | + pull_request_target: |
5 | 11 |
|
6 | | -permissions: read-all |
| 12 | +permissions: |
| 13 | + pull-requests: write |
7 | 14 |
|
8 | 15 | concurrency: |
9 | | - group: ${{ github.workflow }}-${{ github.ref }} |
| 16 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} |
10 | 17 | cancel-in-progress: true |
11 | 18 |
|
12 | 19 | jobs: |
@@ -36,13 +43,17 @@ jobs: |
36 | 43 | echo has_new_authors="yes" >> $GITHUB_ENV |
37 | 44 | fi |
38 | 45 | done < commit-authors.txt |
39 | | - - run: mkdir new-authors |
40 | | - - run: cp new-authors.txt new-authors |
41 | | - - run: echo ${{ github.event.number }} > new-authors/pr-number.txt |
42 | | - - run: ls -l |
43 | | - - name: Upload new authors |
44 | | - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a |
| 46 | + - name: Comment on PR |
| 47 | + if: ${{ env.has_new_authors == 'yes' }} |
| 48 | + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 |
45 | 49 | with: |
46 | | - name: new-authors |
47 | | - path: new-authors |
| 50 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 51 | + script: | |
| 52 | + let msg = 'NOTE: This PR may contain new authors.'; |
| 53 | + await github.rest.issues.createComment({ |
| 54 | + owner: context.repo.owner, |
| 55 | + repo: context.repo.repo, |
| 56 | + issue_number: context.issue.number, |
| 57 | + body: msg |
| 58 | + }); |
48 | 59 |
|
0 commit comments