Skip to content

Commit 2f5927e

Browse files
committed
wip: switch to workflow_dispatch
wip Signed-off-by: George Sapkin <[email protected]>
1 parent b3917d1 commit 2f5927e

File tree

2 files changed

+50
-20
lines changed

2 files changed

+50
-20
lines changed

.github/workflows/formal.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ on:
44
pull_request_target:
55

66
permissions:
7-
# for dispatch
8-
contents: write
7+
contents: read
98
pull-requests: write
109

1110
jobs:
@@ -24,24 +23,30 @@ jobs:
2423
steps:
2524
- name: Trigger build
2625
if: needs.formalities.result == 'success'
27-
uses: peter-evans/repository-dispatch@v3
26+
uses: actions/github-script@v8
2827
with:
29-
repository: ${{ github.repository }}
30-
event-type: run-build
31-
client-payload: '{ "pull_request": { "number": ${{ github.event.pull_request.number }} } }'
28+
github-token: ${{ secrets.DEFAULT_TOKEN }}
29+
script: |
30+
await github.rest.actions.createWorkflowDispatch({
31+
owner: context.repo.owner,
32+
repo: context.repo.repo,
33+
workflow_id: 'multi-arch-test-build.yml',
34+
ref: 'main', // or your default branch
35+
inputs: {
36+
pr_number: context.issue.number.toString(),
37+
},
38+
});
3239
3340
- name: Add 'not following guidelines' label
3441
if: needs.formalities.result == 'failure'
3542
uses: buildsville/[email protected]
3643
with:
37-
token: ${{ secrets.GITHUB_TOKEN }}
3844
labels: "not following guidelines"
3945
type: add
4046

4147
- name: Remove 'not following guidelines' label
4248
if: needs.formalities.result == 'success'
4349
uses: buildsville/[email protected]
4450
with:
45-
token: ${{ secrets.GITHUB_TOKEN }}
4651
labels: "not following guidelines"
4752
type: remove
Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,33 @@
11
name: Test and Build
22

33
on:
4-
repository_dispatch:
5-
types: [run-build]
4+
workflow_dispatch:
5+
inputs:
6+
pr_number:
7+
description: 'The pull request number to build'
8+
required: true
9+
type: 'string'
610

711
permissions:
812
contents: read
13+
statuses: write
914

1015
jobs:
11-
prepare:
12-
name: Feeds Package Test Build
16+
build:
17+
name: Prepare Build Environment
1318
runs-on: ubuntu-latest
19+
outputs:
20+
head_sha: ${{ steps.get_pr_data.outputs.head_sha }}
21+
head_ref: ${{ steps.get_pr_data.outputs.head_ref }}
22+
base_ref: ${{ steps.get_pr_data.outputs.base_ref }}
23+
pr_number: ${{ steps.get_pr_data.outputs.pr_number }}
1424
steps:
1525
- name: Extract PR Data
1626
id: get_pr_data
1727
uses: actions/github-script@v8
1828
with:
1929
script: |
20-
const prNumber = context.payload.client_payload.pull_request.number;
30+
const prNumber = ${{ github.event.inputs.pr_number }};
2131
if (!prNumber) {
2232
core.setFailed('Pull request number not found in the event payload.');
2333
return;
@@ -29,12 +39,27 @@ jobs:
2939
pull_number: prNumber,
3040
});
3141
core.setOutput('head_sha', pr.head.sha);
42+
core.setOutput('head_ref', pr.head.ref);
43+
core.setOutput('base_ref', pr.base.ref);
44+
core.setOutput('pr_number', prNumber);
3245
33-
- name: Checkout PR Code
34-
uses: actions/checkout@v4
46+
- name: Set latest commit status as pending
47+
uses: myrotvorets/set-commit-status-action@master
3548
with:
36-
ref: ${{ steps.get_pr_data.outputs.head_sha }}
37-
build:
38-
name: Feeds Package Test Build
39-
needs: prepare
40-
uses: openwrt/actions-shared-workflows/.github/workflows/multi-arch-test-build.yml@main
49+
sha: ${{ steps.get_pr_data.outputs.head_sha }}
50+
status: pending
51+
52+
- name: Feeds Package Test Build
53+
uses: openwrt/actions-shared-workflows/.github/workflows/multi-arch-test-build.yml@main
54+
env:
55+
GITHUB_EVENT_NAME: pull_request
56+
GITHUB_SHA: ${{ steps.get_pr_data.outputs.head_sha }}
57+
GITHUB_REF: refs/pull/${{ steps.get_pr_data.outputs.pr_number }}/merge
58+
GITHUB_HEAD_REF: ${{ steps.get_pr_data.outputs.head_ref }}
59+
GITHUB_BASE_REF: ${{ steps.get_pr_data.outputs.base_ref }}
60+
61+
- name: Set latest commit status as pending
62+
uses: myrotvorets/set-commit-status-action@master
63+
with:
64+
sha: ${{ steps.get_pr_data.outputs.head_sha }}
65+
status: ${{ job.status }}

0 commit comments

Comments
 (0)