Skip to content

Commit 64d5da6

Browse files
authored
workflows: Unsplit pr-subscriber (llvm#69748)
This is essentially a revert of 1ed7108. It is safe to use the pull_request_target event for pr-subscriber, because it does not checkout any code from the pull request branch.
1 parent 67a53ae commit 64d5da6

File tree

3 files changed

+5
-100
lines changed

3 files changed

+5
-100
lines changed

.github/workflows/pr-receive-label.yml

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

.github/workflows/pr-subscriber-wait.py

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

.github/workflows/pr-subscriber.yml

Lines changed: 5 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
name: PR Subscriber
22

33
on:
4-
workflow_run:
5-
workflows: ["PR Receive Label"]
4+
pull_request_target:
65
types:
7-
- completed
6+
- labeled
87

98
permissions:
10-
actions: read
119
contents: read
1210

1311
jobs:
1412
auto-subscribe:
1513
runs-on: ubuntu-latest
16-
if: >
17-
github.repository == 'llvm/llvm-project' &&
18-
github.event.workflow_run.event == 'pull_request' &&
19-
github.event.workflow_run.conclusion == 'success'
14+
if: github.repository == 'llvm/llvm-project'
2015
steps:
2116
- name: Setup Automation Script
2217
run: |
@@ -26,47 +21,10 @@ jobs:
2621
chmod a+x github-automation.py
2722
pip install -r requirements.txt
2823
29-
- name: 'Wait for other actions'
30-
# We can't use the concurrency tag for these jobs, because it will
31-
# cancel pending jobs if another job is running.
32-
env:
33-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34-
run: |
35-
python3 pr-subscriber-wait.py
36-
37-
38-
# From: https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
39-
# Updated version here: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#using-data-from-the-triggering-workflow
40-
- name: 'Download artifact'
41-
uses: actions/github-script@v6
42-
with:
43-
script: |
44-
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
45-
owner: context.repo.owner,
46-
repo: context.repo.repo,
47-
run_id: context.payload.workflow_run.id
48-
});
49-
const matchArtifact = artifacts.data.artifacts.find((artifact) =>
50-
artifact.name === 'pr'
51-
);
52-
const download = await github.rest.actions.downloadArtifact({
53-
owner: context.repo.owner,
54-
repo: context.repo.repo,
55-
artifact_id: matchArtifact.id,
56-
archive_format: 'zip'
57-
});
58-
const { writeFileSync } = require('node:fs');
59-
writeFileSync('${{ github.workspace }}/pr.zip', Buffer.from(download.data));
60-
61-
- run: unzip pr.zip
62-
6324
- name: Update watchers
64-
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
6525
run: |
66-
PR_NUMBER=$(cat NR)
67-
LABEL_NAME=$(cat LABEL)
6826
./github-automation.py \
6927
--token '${{ secrets.ISSUE_SUBSCRIBER_TOKEN }}' \
7028
pr-subscriber \
71-
--issue-number "$PR_NUMBER" \
72-
--label-name "$LABEL_NAME"
29+
--issue-number "${{ github.event.number }}" \
30+
--label-name "${{ github.event.label.name }}"

0 commit comments

Comments
 (0)