chore: replace deprecated maintain-one-comment with github-script#1563
Conversation
|
🚀 Cloudflare Workers Preview has been successfully deployed! Preview URL: https://md-pr-1563.doocs.workers.dev Built with commit 0b581f0 |
There was a problem hiding this comment.
Pull request overview
This PR updates GitHub Actions workflows to replace the removed actions-cool/maintain-one-comment action with actions/github-script@v9 and direct calls to github.rest.issues.createComment, keeping preview/build status reporting on PRs working.
Changes:
- Replaced Surge preview success/failure/build-failure PR commenting steps with
actions/github-script@v9. - Replaced Cloudflare Workers preview PR commenting step with
actions/github-script@v9. - Switched from “maintain one comment” behavior to unconditional
issues.createCommentcalls.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| .github/workflows/surge-preview-deploy.yml | Replaces maintain-one-comment with github-script for Surge preview status comments. |
| .github/workflows/cloudflare-preview.yml | Replaces maintain-one-comment with github-script for Cloudflare preview URL comment. |
| - name: Comment PR with preview link | ||
| uses: actions-cool/maintain-one-comment@v3 | ||
| uses: actions/github-script@v9 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| body: | | ||
| 🚀 Surge Preview has been successfully deployed! | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| script: | | ||
| const prNumber = ${{ steps.pr.outputs.id }}; | ||
| const deployUrl = 'https://doocs-md-preview-pr-${{ steps.pr.outputs.id }}.surge.sh'; | ||
| const commitSha = '${{ github.event.workflow_run.head_sha }}'; | ||
|
|
||
| **Preview URL:** https://doocs-md-preview-pr-${{ steps.pr.outputs.id }}.surge.sh | ||
| await github.rest.issues.createComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: prNumber, | ||
| body: `🚀 Surge Preview has been successfully deployed! | ||
|
|
||
| <sub>Built with commit ${{ github.event.workflow_run.head_sha }}</sub> | ||
| **Preview URL:** ${deployUrl} | ||
|
|
||
| <!-- Surge Preview Comment --> | ||
| body-include: '<!-- Surge Preview Comment -->' | ||
| number: ${{ steps.pr.outputs.id }} | ||
| <sub>Built with commit ${commitSha}</sub> | ||
|
|
||
| <!-- Surge Preview Comment -->` | ||
| }); |
| body: `🚀 Surge Preview has been successfully deployed! | ||
|
|
||
| <sub>Built with commit ${{ github.event.workflow_run.head_sha }}</sub> | ||
| **Preview URL:** ${deployUrl} | ||
|
|
||
| <!-- Surge Preview Comment --> | ||
| body-include: '<!-- Surge Preview Comment -->' | ||
| number: ${{ steps.pr.outputs.id }} | ||
| <sub>Built with commit ${commitSha}</sub> | ||
|
|
||
| <!-- Surge Preview Comment -->` |
| body: `😭 Surge Preview deployment failed. | ||
|
|
||
| Please check the [workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details. | ||
| Please check the [workflow run](${workflowRunUrl}) for details. | ||
|
|
||
| <!-- Surge Preview Comment --> | ||
| body-include: '<!-- Surge Preview Comment -->' | ||
| number: ${{ steps.pr.outputs.id }} | ||
| <!-- Surge Preview Comment -->` |
| body: `😭 Surge Preview build failed. | ||
|
|
||
| Please check the [workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}) for details. | ||
| Please check the [workflow run](${workflowRunUrl}) for details. | ||
|
|
||
| <!-- Surge Preview Comment --> | ||
| body-include: '<!-- Surge Preview Comment -->' | ||
| number: ${{ steps.pr.outputs.id }} | ||
| <!-- Surge Preview Comment -->` |
| - name: Comment PR with preview link | ||
| uses: actions-cool/maintain-one-comment@v3 | ||
| uses: actions/github-script@v9 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| body: | | ||
| 🚀 Cloudflare Workers Preview has been successfully deployed! | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| script: | | ||
| const prNumber = ${{ github.event.pull_request.number }}; | ||
| const deployUrl = '${{ steps.deployment-url.outputs.url }}'; | ||
| const commitSha = '${{ github.event.pull_request.head.sha }}'; | ||
|
|
||
| **Preview URL:** ${{ steps.deployment-url.outputs.url }} | ||
| await github.rest.issues.createComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: prNumber, | ||
| body: `🚀 Cloudflare Workers Preview has been successfully deployed! | ||
|
|
||
| <sub>Built with commit ${{ github.event.pull_request.head.sha }}</sub> | ||
| **Preview URL:** ${deployUrl} | ||
|
|
||
| <!-- Cloudflare Preview Comment --> | ||
| body-include: '<!-- Cloudflare Preview Comment -->' | ||
| number: ${{ github.event.pull_request.number }} | ||
| <sub>Built with commit ${commitSha}</sub> | ||
|
|
||
| <!-- Cloudflare Preview Comment -->` | ||
| }); |
| body: `🚀 Cloudflare Workers Preview has been successfully deployed! | ||
|
|
||
| <sub>Built with commit ${{ github.event.pull_request.head.sha }}</sub> | ||
| **Preview URL:** ${deployUrl} | ||
|
|
||
| <!-- Cloudflare Preview Comment --> | ||
| body-include: '<!-- Cloudflare Preview Comment -->' | ||
| number: ${{ github.event.pull_request.number }} | ||
| <sub>Built with commit ${commitSha}</sub> | ||
|
|
||
| <!-- Cloudflare Preview Comment -->` |
8a53c79 to
1eb45c4
Compare
|
@copilot 重新 review |
Both issues raised in the original review have been addressed in commit
|
The actions-cool/maintain-one-comment action has been removed. Replace
all 4 usages across cloudflare-preview.yml and surge-preview-deploy.yml
with actions/github-script@9 calling issues.createComment directly.
Also restore the single-comment behavior by listing PR comments,
locating the existing one via the HTML marker, and updating it
instead of creating duplicates on every re-run. Comment bodies are
now built with array.join('\n') to avoid leading-space Markdown issues.
Additionally, upgrade dawidd6/action-download-artifact to v14 and pin
it to prevent further automated upgrades.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1eb45c4 to
0b581f0
Compare
|
🗑️ Cloudflare Workers preview deployment has been cleaned up. |
The actions-cool/maintain-one-comment action has been removed. Replace all 4 usages across cloudflare-preview.yml and surge-preview-deploy.yml with actions/github-script@v9 calling issues.createComment directly.