|
| 1 | +name: Pull Request build |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [opened, synchronize, reopened] |
| 6 | + |
| 7 | +jobs: |
| 8 | + build-esp32s2: |
| 9 | + uses: ./.github/workflows/pr-build-env.yml |
| 10 | + secrets: inherit |
| 11 | + with: |
| 12 | + env: esp32s2 |
| 13 | + is_esp32: true |
| 14 | + |
| 15 | + build-esp32s3: |
| 16 | + uses: ./.github/workflows/pr-build-env.yml |
| 17 | + secrets: inherit |
| 18 | + with: |
| 19 | + env: esp32s3 |
| 20 | + is_esp32: true |
| 21 | + |
| 22 | + build-esp32c3: |
| 23 | + uses: ./.github/workflows/pr-build-env.yml |
| 24 | + secrets: inherit |
| 25 | + with: |
| 26 | + env: esp32c3 |
| 27 | + is_esp32: true |
| 28 | + |
| 29 | + build-esp32: |
| 30 | + uses: ./.github/workflows/pr-build-env.yml |
| 31 | + secrets: inherit |
| 32 | + with: |
| 33 | + env: esp32 |
| 34 | + is_esp32: true |
| 35 | + |
| 36 | + build-esp32solo: |
| 37 | + uses: ./.github/workflows/pr-build-env.yml |
| 38 | + secrets: inherit |
| 39 | + with: |
| 40 | + env: esp32solo |
| 41 | + is_esp32: true |
| 42 | + |
| 43 | + build-esp8266: |
| 44 | + uses: ./.github/workflows/pr-build-env.yml |
| 45 | + secrets: inherit |
| 46 | + with: |
| 47 | + env: esp8266 |
| 48 | + is_esp32: false |
| 49 | + |
| 50 | + comment: |
| 51 | + needs: |
| 52 | + - build-esp32s2 |
| 53 | + - build-esp32s3 |
| 54 | + - build-esp32c3 |
| 55 | + - build-esp32 |
| 56 | + - build-esp32solo |
| 57 | + - build-esp8266 |
| 58 | + runs-on: ubuntu-latest |
| 59 | + permissions: |
| 60 | + pull-requests: write |
| 61 | + steps: |
| 62 | + - name: Download all artifacts |
| 63 | + uses: actions/download-artifact@v4 |
| 64 | + with: |
| 65 | + path: artifacts |
| 66 | + |
| 67 | + - name: Post PR comment with download links |
| 68 | + uses: actions/github-script@v7 |
| 69 | + with: |
| 70 | + script: | |
| 71 | + const { owner, repo } = context.repo; |
| 72 | + const prNumber = context.payload.pull_request.number; |
| 73 | + const runId = context.runId; |
| 74 | + const runUrl = `https://github.com/${owner}/${repo}/actions/runs/${runId}`; |
| 75 | +
|
| 76 | + const envs = ['esp32s2', 'esp32s3', 'esp32c3', 'esp32', 'esp32solo', 'esp8266']; |
| 77 | + const lines = envs.map(env => |
| 78 | + `- **${env}**: [${env}.zip](${runUrl}/artifacts) (see artifacts on the [workflow run](${runUrl}))` |
| 79 | + ); |
| 80 | +
|
| 81 | + const body = [ |
| 82 | + '## 🔧 PR Build Artifacts', |
| 83 | + '', |
| 84 | + 'All environments built successfully. Download the zip files from the workflow run artifacts:', |
| 85 | + '', |
| 86 | + ...lines, |
| 87 | + '', |
| 88 | + `> [View all artifacts on the workflow run](${runUrl})`, |
| 89 | + ].join('\n'); |
| 90 | +
|
| 91 | + // Find and delete any previous bot comment to keep the PR clean |
| 92 | + const comments = await github.rest.issues.listComments({ owner, repo, issue_number: prNumber }); |
| 93 | + for (const comment of comments.data) { |
| 94 | + if (comment.user.type === 'Bot' && comment.body.includes('PR Build Artifacts')) { |
| 95 | + await github.rest.issues.deleteComment({ owner, repo, comment_id: comment.id }); |
| 96 | + } |
| 97 | + } |
| 98 | +
|
| 99 | + await github.rest.issues.createComment({ owner, repo, issue_number: prNumber, body }); |
0 commit comments