Skip to content

Commit 47bb041

Browse files
committed
workflows: Unsplit new-prs
This is essentially a revert of 91fdb20. It is safe to use the pull_request_target event for new-prs, because it does not checkout any code from the pull request branch.
1 parent b2e487d commit 47bb041

File tree

2 files changed

+15
-72
lines changed

2 files changed

+15
-72
lines changed

.github/workflows/new-prs.yml

Lines changed: 15 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,33 @@
11
name: "Labelling new pull requests"
22
on:
3-
workflow_run:
4-
workflows: ["PR Receive"]
3+
# It's safe to use pull_request_target here, because we aren't checking out
4+
# code from the pull request branch.
5+
# See https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
6+
pull_request_target:
7+
types:
8+
- opened
9+
- reopened
10+
- ready_for_review
11+
- synchronize
512

613
jobs:
714
automate-prs-labels:
815
permissions:
916
contents: read
1017
pull-requests: write
1118
runs-on: ubuntu-latest
19+
# Ignore PRs with more than 10 commits. Pull requests with a lot of
20+
# commits tend to be accidents usually when someone made a mistake while trying
21+
# to rebase. We want to ignore these pull requests to avoid excessive
22+
# notifications.
1223
if: >
1324
github.repository == 'llvm/llvm-project' &&
14-
github.event.workflow_run.event == 'pull_request_target' &&
15-
github.event.workflow_run.conclusion == 'success'
25+
github.event.pull_request.draft == false &&
26+
github.event.pull_request.commits < 10
1627
steps:
17-
# From: https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
18-
# Updated version here: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#using-data-from-the-triggering-workflow
19-
- name: Debug
20-
run: |
21-
echo "Event: ${{ github.event.workflow_run.event }} Conclusion: ${{ github.event.workflow_run.conclusion }}"
22-
- name: 'Download artifact'
23-
uses: actions/github-script@v6
24-
with:
25-
script: |
26-
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
27-
owner: context.repo.owner,
28-
repo: context.repo.repo,
29-
run_id: context.payload.workflow_run.id
30-
});
31-
const matchArtifact = artifacts.data.artifacts.find((artifact) =>
32-
artifact.name === 'pr'
33-
);
34-
const download = await github.rest.actions.downloadArtifact({
35-
owner: context.repo.owner,
36-
repo: context.repo.repo,
37-
artifact_id: matchArtifact.id,
38-
archive_format: 'zip'
39-
});
40-
const { writeFileSync } = require('node:fs');
41-
writeFileSync('${{ github.workspace }}/pr.zip', Buffer.from(download.data));
42-
43-
- run: unzip pr.zip
44-
45-
- name: "Get PR Number"
46-
id: vars
47-
run:
48-
echo "pr-number=$(cat NR)" >> "$GITHUB_OUTPUT"
49-
5028
- uses: actions/labeler@v4
5129
with:
5230
configuration-path: .github/new-prs-labeler.yml
5331
# workaround for https://github.com/actions/labeler/issues/112
5432
sync-labels: ''
5533
repo-token: ${{ secrets.ISSUE_SUBSCRIBER_TOKEN }}
56-
pr-number: ${{ steps.vars.outputs.pr-number }}

.github/workflows/pr-receive.yml

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

0 commit comments

Comments
 (0)