|
| 1 | +name: Plugin Artifact for PR |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - 'plugins/**' |
| 7 | + |
| 8 | +jobs: |
| 9 | + create-plugin-artifact: |
| 10 | + name: Create Plugin Artifact |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + steps: |
| 14 | + - name: Checkout |
| 15 | + uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - name: Get changed plugin directory |
| 18 | + id: plugin |
| 19 | + run: | |
| 20 | + git fetch --prune --unshallow |
| 21 | + plugin=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep '^plugins/' | head -1 | cut -d/ -f2) |
| 22 | + echo "slug=$plugin" >> $GITHUB_OUTPUT |
| 23 | +
|
| 24 | + - name: Create plugin artifact |
| 25 | + uses: ./.github/actions/create-plugin-artifact |
| 26 | + env: |
| 27 | + PLUGIN_SLUG: ${{ steps.plugin.outputs.slug }} |
| 28 | + with: |
| 29 | + slug: ${{ env.PLUGIN_SLUG }} |
| 30 | + |
| 31 | + - name: Comment with artifact link |
| 32 | + uses: actions/github-script@v7 |
| 33 | + env: |
| 34 | + PLUGIN_SLUG: ${{ steps.plugin.outputs.slug }} |
| 35 | + with: |
| 36 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 37 | + script: | |
| 38 | + const pr = context.payload.pull_request; |
| 39 | + const runId = context.runId; |
| 40 | + const artifactUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`; |
| 41 | + const slug = process.env.PLUGIN_SLUG; |
| 42 | + const body = `ℹ️ [Download the ${slug} plugin artifact from this workflow run](${artifactUrl}) (see the 'Artifacts' section at the bottom).`; |
| 43 | + await github.rest.issues.createComment({ |
| 44 | + issue_number: pr.number, |
| 45 | + owner: context.repo.owner, |
| 46 | + repo: context.repo.repo, |
| 47 | + body |
| 48 | + }); |
0 commit comments