Skip to content

Commit 10eefa8

Browse files
committed
split workflow
Signed-off-by: Anas Nashif <[email protected]>
1 parent 5957f41 commit 10eefa8

File tree

2 files changed

+97
-7
lines changed

2 files changed

+97
-7
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Pull Request Assigner Completion Workflow
2+
3+
# read-write repo token
4+
# access to secrets
5+
on:
6+
workflow_run:
7+
workflows: ["Pull Request Assigner"]
8+
types:
9+
- completed
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
assignment:
16+
name: Pull Request Assignment
17+
runs-on: ubuntu-24.04
18+
if: >
19+
github.event.workflow_run.event == 'pull_request' &&
20+
github.event.workflow_run.conclusion == 'success'
21+
22+
steps:
23+
- name: 'Download artifact'
24+
uses: actions/[email protected]
25+
with:
26+
script: |
27+
var artifacts = await github.actions.listWorkflowRunArtifacts({
28+
owner: context.repo.owner,
29+
repo: context.repo.repo,
30+
run_id: ${{github.event.workflow_run.id }},
31+
});
32+
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
33+
return artifact.name == "pr"
34+
})[0];
35+
var download = await github.actions.downloadArtifact({
36+
owner: context.repo.owner,
37+
repo: context.repo.repo,
38+
artifact_id: matchArtifact.id,
39+
archive_format: 'zip',
40+
});
41+
var fs = require('fs');
42+
fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data));
43+
- run: unzip pr.zip
44+
45+
- name: Check out source code
46+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
47+
with:
48+
fetch-depth: 0
49+
persist-credentials: false
50+
51+
- name: Set up Python
52+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
53+
with:
54+
python-version: 3.12
55+
cache: pip
56+
cache-dependency-path: scripts/requirements-actions.txt
57+
58+
- name: Install Python packages
59+
run: |
60+
pip install -r scripts/requirements-actions.txt --require-hashes
61+
62+
- name: Run assignment script
63+
env:
64+
GITHUB_TOKEN: ${{ secrets.ZB_PR_ASSIGNER_GITHUB_TOKEN }}
65+
run: |
66+
FLAGS="-v"
67+
FLAGS+=" -o ${{ github.event.repository.owner.login }}"
68+
FLAGS+=" -r ${{ github.event.repository.name }}"
69+
FLAGS+=" -M MAINTAINERS.yml"
70+
if [ "${{ github.event_name }}" = "pull_request_target" ]; then
71+
FLAGS+=" -P ${{ github.event.pull_request.number }} -c origin/${{ github.base_ref }}.."
72+
elif [ "${{ github.event_name }}" = "issues" ]; then
73+
FLAGS+=" -I ${{ github.event.issue.number }}"
74+
elif [ "${{ github.event_name }}" = "schedule" ]; then
75+
FLAGS+=" --modules"
76+
else
77+
echo "Unknown event: ${{ github.event_name }}"
78+
exit 1
79+
fi
80+
81+
python3 scripts/set_assignees.py $FLAGS

.github/workflows/assigner.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Pull Request Assigner
22

33
on:
4-
pull_request_target:
4+
pull_request:
55
types:
66
- opened
77
- synchronize
@@ -31,7 +31,6 @@ jobs:
3131
- name: Check out source code
3232
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3333
with:
34-
ref: ${{ github.event.pull_request.head.sha }}
3534
fetch-depth: 0
3635
persist-credentials: false
3736

@@ -50,15 +49,11 @@ jobs:
5049
env:
5150
GITHUB_TOKEN: ${{ secrets.ZB_PR_ASSIGNER_GITHUB_TOKEN }}
5251
run: |
53-
west init -l . || true
54-
git log | head -n 10
55-
git diff origin/${{ github.base_ref }}..
56-
5752
FLAGS="-v"
5853
FLAGS+=" -o ${{ github.event.repository.owner.login }}"
5954
FLAGS+=" -r ${{ github.event.repository.name }}"
6055
FLAGS+=" -M MAINTAINERS.yml"
61-
if [ "${{ github.event_name }}" = "pull_request_target" ]; then
56+
if [ "${{ github.event_name }}" = "pull_request" ]; then
6257
FLAGS+=" -P ${{ github.event.pull_request.number }} -c origin/${{ github.base_ref }}.."
6358
elif [ "${{ github.event_name }}" = "issues" ]; then
6459
FLAGS+=" -I ${{ github.event.issue.number }}"
@@ -70,3 +65,17 @@ jobs:
7065
fi
7166

7267
python3 scripts/set_assignees.py $FLAGS
68+
69+
- name: Save PR number
70+
if: >
71+
github.event.workflow_run.event == 'pull_request'
72+
run: |
73+
mkdir -p ./pr
74+
echo ${{ github.event.number }} > ./pr/NR
75+
- uses: actions/upload-artifact@v2
76+
if: >
77+
github.event.workflow_run.event == 'pull_request'
78+
with:
79+
name: pr
80+
path: pr/
81+

0 commit comments

Comments
 (0)