|
1 | 1 | name: Test and Build |
2 | 2 |
|
3 | 3 | on: |
4 | | - issue_comment: |
5 | | - types: [created, edited] |
| 4 | + repository_dispatch: |
| 5 | + types: [run-build] |
6 | 6 |
|
7 | 7 | permissions: |
8 | 8 | contents: read |
9 | 9 |
|
10 | 10 | jobs: |
11 | | - formalities: |
12 | | - name: Check Formalities Result |
13 | | - if: ${{ github.event.issue.pull_request }} |
14 | | - runs-on: ubuntu-slim |
15 | | - outputs: |
16 | | - build: ${{ steps.parse.outputs.build }} |
| 11 | + prepare: |
| 12 | + name: Feeds Package Test Build |
| 13 | + runs-on: ubuntu-latest |
17 | 14 | steps: |
18 | | - - name: Get PR info |
19 | | - id: get_pr |
| 15 | + - name: Extract PR Data |
| 16 | + id: get_pr_data |
20 | 17 | uses: actions/github-script@v8 |
21 | 18 | with: |
22 | 19 | script: | |
| 20 | + const prNumber = context.payload.client_payload.pull_request.number; |
| 21 | + if (!prNumber) { |
| 22 | + core.setFailed('Pull request number not found in the event payload.'); |
| 23 | + return; |
| 24 | + } |
| 25 | +
|
23 | 26 | const { data: pr } = await github.rest.pulls.get({ |
24 | 27 | owner: context.repo.owner, |
25 | 28 | repo: context.repo.repo, |
26 | | - pull_number: context.issue.number, |
| 29 | + pull_number: prNumber, |
27 | 30 | }); |
28 | | - core.setOutput('sha', pr.head.sha); |
| 31 | + core.setOutput('head_sha', pr.head.sha); |
29 | 32 |
|
30 | | - - name: Checkout PR |
| 33 | + - name: Checkout PR Code |
31 | 34 | uses: actions/checkout@v4 |
32 | 35 | with: |
33 | | - ref: ${{ steps.get_pr.outputs.sha }} |
34 | | - |
35 | | - - name: Parse comment for build status |
36 | | - id: parse |
37 | | - uses: actions/github-script@v8 |
38 | | - env: |
39 | | - BOT_USERNAME: ${{ vars.BOT_USERNAME }} |
40 | | - with: |
41 | | - script: | |
42 | | - const allowedBot = process.env.BOT_USERNAME; |
43 | | - if (!allowedBot || context.payload.sender.login.toLowerCase() !== allowedBot.toLowerCase()) { |
44 | | - console.log(`Comment is not from the allowed bot ('${allowedBot}'). Sender was '${context.payload.sender.login}'. Skipping.`); |
45 | | - core.setOutput('build', 'skip'); |
46 | | - return; |
47 | | - } |
48 | | -
|
49 | | - const body = context.payload.comment.body; |
50 | | - const marker = "<!-- BUILD_LOOKUP -->"; |
51 | | -
|
52 | | - if (!body.includes(marker)) { |
53 | | - console.log('Comment does not contain the build marker. Skipping.'); |
54 | | - core.setOutput('build', 'skip'); |
55 | | - return; |
56 | | - } |
57 | | -
|
58 | | - const regex = /Build info<!-- (.*) -->/; |
59 | | - const match = body.match(regex); |
60 | | -
|
61 | | - if (match && match[1]) { |
62 | | - const { build } = JSON.parse(match[1]); |
63 | | - core.setOutput('build', build.toString()); |
64 | | - } |
65 | | -
|
| 36 | + ref: ${{ steps.get_pr_data.outputs.head_sha }} |
66 | 37 | build: |
67 | 38 | name: Feeds Package Test Build |
68 | | - needs: formalities |
69 | | - if: needs.formalities.outputs.build == 'true' |
| 39 | + needs: prepare |
70 | 40 | uses: openwrt/actions-shared-workflows/.github/workflows/multi-arch-test-build.yml@main |
0 commit comments