Skip to content

Commit c387e79

Browse files
committed
github-ci: consolidate new authors check into a single workflow
Replace the two-workflow pattern (authors.yml + authors-done.yml) with a single pull_request_target workflow. I'm not sure this was possible when this job was originally created, but apparently it is now.
1 parent 0eda09f commit c387e79

2 files changed

Lines changed: 22 additions & 64 deletions

File tree

.github/workflows/authors-done.yml

Lines changed: 0 additions & 53 deletions
This file was deleted.

.github/workflows/authors.yml

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
name: New Authors Check
22

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.
39
on:
4-
pull_request:
10+
pull_request_target:
511

6-
permissions: read-all
12+
permissions:
13+
pull-requests: write
714

815
concurrency:
9-
group: ${{ github.workflow }}-${{ github.ref }}
16+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
1017
cancel-in-progress: true
1118

1219
jobs:
@@ -36,13 +43,17 @@ jobs:
3643
echo has_new_authors="yes" >> $GITHUB_ENV
3744
fi
3845
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
4549
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+
});
4859

0 commit comments

Comments
 (0)