|
9 | 9 | - 'plugins/*/**.json'
|
10 | 10 |
|
11 | 11 | jobs:
|
12 |
| - create-plugin-artifact: |
13 |
| - name: Create Plugin Artifact |
| 12 | + detect-plugins: |
| 13 | + name: Detect Changed Plugins |
14 | 14 | runs-on: ubuntu-latest
|
15 |
| - |
| 15 | + outputs: |
| 16 | + plugins: ${{ steps.plugin.outputs.plugins }} |
| 17 | + has-plugins: ${{ steps.plugin.outputs.has-plugins }} |
16 | 18 | steps:
|
17 | 19 | - name: Checkout
|
18 | 20 | uses: actions/checkout@v4
|
19 | 21 |
|
20 |
| - - name: Get changed plugin directory |
| 22 | + - name: Get changed plugin directories |
21 | 23 | id: plugin
|
22 | 24 | run: |
|
23 | 25 | bash .github/scripts/get_plugin_slug.sh \
|
24 | 26 | ${{ github.event.pull_request.base.sha }} \
|
25 | 27 | ${{ github.event.pull_request.head.sha }}
|
26 | 28 |
|
27 |
| - - name: Create plugin artifact |
| 29 | + create-plugin-artifacts: |
| 30 | + name: Create Plugin Artifacts |
| 31 | + runs-on: ubuntu-latest |
| 32 | + needs: detect-plugins |
| 33 | + if: needs.detect-plugins.outputs.has-plugins == 'true' |
| 34 | + strategy: |
| 35 | + fail-fast: false |
| 36 | + matrix: |
| 37 | + plugin: ${{ fromJson(needs.detect-plugins.outputs.plugins) }} |
| 38 | + |
| 39 | + steps: |
| 40 | + - name: Checkout |
| 41 | + uses: actions/checkout@v4 |
| 42 | + |
| 43 | + - name: Create plugin artifact for ${{ matrix.plugin }} |
28 | 44 | uses: ./.github/actions/create-plugin-artifact
|
29 |
| - env: |
30 |
| - PLUGIN_SLUG: ${{ steps.plugin.outputs.slug }} |
31 | 45 | with:
|
32 |
| - slug: ${{ env.PLUGIN_SLUG }} |
| 46 | + slug: ${{ matrix.plugin }} |
33 | 47 | composer-options: '--no-progress --optimize-autoloader --no-dev'
|
34 | 48 |
|
35 |
| - - name: Comment with artifact link |
| 49 | + comment-on-pr: |
| 50 | + name: Comment with Artifact Links |
| 51 | + runs-on: ubuntu-latest |
| 52 | + needs: [detect-plugins, create-plugin-artifacts] |
| 53 | + if: needs.detect-plugins.outputs.has-plugins == 'true' |
| 54 | + steps: |
| 55 | + - name: Comment with artifact links |
36 | 56 | uses: actions/github-script@v7
|
37 | 57 | env:
|
38 |
| - PLUGIN_SLUG: ${{ steps.plugin.outputs.slug }} |
| 58 | + PLUGINS: ${{ needs.detect-plugins.outputs.plugins }} |
39 | 59 | with:
|
40 | 60 | github-token: ${{ secrets.GITHUB_TOKEN }}
|
41 | 61 | script: |
|
42 | 62 | const pr = context.payload.pull_request;
|
43 | 63 | const runId = context.runId;
|
44 | 64 | const artifactUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
|
45 |
| - const slug = process.env.PLUGIN_SLUG; |
46 |
| - const body = `ℹ️ [Download the latest ${slug} plugin zip from this PR](${artifactUrl})\n<em>(See the 'Artifacts' section at the bottom)</em>`; |
| 65 | + const plugins = JSON.parse(process.env.PLUGINS); |
| 66 | + |
| 67 | + let body = '## 📦 Plugin Artifacts Ready!\n\n'; |
| 68 | + body += `[Download from GitHub Actions run](${artifactUrl})\n\n`; |
| 69 | + body += '**Available plugins:**\n'; |
| 70 | + plugins.forEach(plugin => { |
| 71 | + body += `- ✅ ${plugin}.zip\n`; |
| 72 | + }); |
| 73 | + body += '\n<em>See the "Artifacts" section at the bottom of the Actions run page</em>'; |
47 | 74 |
|
48 | 75 | // Find existing comment from this bot
|
49 | 76 | const comments = await github.rest.issues.listComments({
|
|
55 | 82 | const botComment = comments.data.find(comment =>
|
56 | 83 | comment.user.type === 'Bot' &&
|
57 | 84 | comment.user.login === 'github-actions[bot]' &&
|
58 |
| - comment.body.includes(`ℹ️ [Download the latest ${slug} plugin zip from this PR]`) |
| 85 | + comment.body.includes('## 📦 Plugin Artifacts Ready!') |
59 | 86 | );
|
60 | 87 |
|
61 | 88 | if (botComment) {
|
|
0 commit comments