|
4 | 4 | pull_request: |
5 | 5 | paths: |
6 | 6 | - 'plugins/**.php' |
| 7 | + - 'plugins/**.js' |
| 8 | + - 'plugins/**.css' |
| 9 | + - 'plugins/**.json' |
7 | 10 |
|
8 | 11 | jobs: |
9 | 12 | create-plugin-artifact: |
@@ -39,10 +42,36 @@ jobs: |
39 | 42 | const runId = context.runId; |
40 | 43 | const artifactUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`; |
41 | 44 | 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({ |
| 45 | + const body = `ℹ️ [Download the latest ${slug} plugin zip from this PR](${artifactUrl})\n<em>(See the 'Artifacts' section at the bottom)</em>`; |
| 46 | + |
| 47 | + // Find existing comment from this bot |
| 48 | + const comments = await github.rest.issues.listComments({ |
44 | 49 | issue_number: pr.number, |
45 | 50 | owner: context.repo.owner, |
46 | | - repo: context.repo.repo, |
47 | | - body |
| 51 | + repo: context.repo.repo |
48 | 52 | }); |
| 53 | + |
| 54 | + const botComment = comments.data.find(comment => |
| 55 | + comment.user.type === 'Bot' && |
| 56 | + comment.user.login === 'github-actions[bot]' && |
| 57 | + comment.body.includes(`ℹ️ [Download the latest ${slug} plugin zip from this PR]`) |
| 58 | + ); |
| 59 | + |
| 60 | + if (botComment) { |
| 61 | + // Update existing comment |
| 62 | + core.info(`Updating existing comment with ID: ${botComment.id}`); |
| 63 | + await github.rest.issues.updateComment({ |
| 64 | + comment_id: botComment.id, |
| 65 | + owner: context.repo.owner, |
| 66 | + repo: context.repo.repo, |
| 67 | + body |
| 68 | + }); |
| 69 | + } else { |
| 70 | + // Create new comment |
| 71 | + await github.rest.issues.createComment({ |
| 72 | + issue_number: pr.number, |
| 73 | + owner: context.repo.owner, |
| 74 | + repo: context.repo.repo, |
| 75 | + body |
| 76 | + }); |
| 77 | + } |
0 commit comments