forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (52 loc) · 2.09 KB
/
new-prs.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
name: "Labelling new pull requests"
on:
workflow_run:
workflows: ["PR Receive"]
jobs:
automate-prs-labels:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
if: >
github.repository == 'llvm/llvm-project' &&
github.event.workflow_run.event == 'pull_request_target' &&
github.event.workflow_run.conclusion == 'success'
steps:
# From: https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
# Updated version here: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#using-data-from-the-triggering-workflow
- name: Debug
run: |
echo "Event: ${{ github.event.workflow_run.event }} Conclusion: ${{ github.event.workflow_run.conclusion }}"
- name: 'Download artifact'
uses: actions/github-script@v6
with:
script: |
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id
});
const matchArtifact = artifacts.data.artifacts.find((artifact) =>
artifact.name === 'pr'
);
const download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip'
});
const { writeFileSync } = require('node:fs');
writeFileSync('${{ github.workspace }}/pr.zip', Buffer.from(download.data));
- run: unzip pr.zip
- name: "Get PR Number"
id: vars
run:
echo "pr-number=$(cat NR)" >> "$GITHUB_OUTPUT"
- uses: actions/labeler@v4
with:
configuration-path: .github/new-prs-labeler.yml
# workaround for https://github.com/actions/labeler/issues/112
sync-labels: ''
repo-token: ${{ secrets.ISSUE_SUBSCRIBER_TOKEN }}
pr-number: ${{ steps.vars.outputs.pr-number }}