-
Notifications
You must be signed in to change notification settings - Fork 94
60 lines (57 loc) · 2.13 KB
/
auto-assign-pr.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
57
58
59
60
name: (Privileged) Auto Assign PR
# This job is run when auto-assign-pr-schedule.yaml is finished.
# This is to avoid pull_request or pull_request_target as per
# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/.
#
# This job requires origin PR number which is not populated for external forks.
# Instead, we use artifact with the auto-assign-pr name.
on:
workflow_run:
workflows: [ "Auto Assign PR" ]
types:
- completed
jobs:
auto-assign:
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
steps:
- name: 'Download parameter'
# NOTE(bwplotka): We keep 3.1.0 version as listWorkflowRunArtifacts is not
# present in v6 for some reason (to be researched why).
uses: actions/[email protected]
with:
script: |
const artifacts = await github.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{github.event.workflow_run.id }},
});
const matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "auto-assign-pr"
})[0];
const download = await github.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
const fs = require('fs');
fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data));
- run: unzip pr.zip
- name: 'Get PR number'
uses: actions/github-script@v6
id: set-result
with:
script: |
const fs = require('fs');
return Number(fs.readFileSync('./NR'));
result-encoding: string
- name: 'Auto-assign issue'
uses: pozil/auto-assign-issue@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
assignees: ${{ secrets.DEFAULT_ISSUE_ASSIGNEE }}
abortIfPreviousAssignees: true
issueNumber: ${{ steps.set-result.outputs.result }}