Skip to content

chore: replace deprecated maintain-one-comment with github-script#1563

Merged
yanglbme merged 1 commit into
mainfrom
chore/replace-maintain-one-comment
May 21, 2026
Merged

chore: replace deprecated maintain-one-comment with github-script#1563
yanglbme merged 1 commit into
mainfrom
chore/replace-maintain-one-comment

Conversation

@yanglbme
Copy link
Copy Markdown
Member

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.

Copilot AI review requested due to automatic review settings May 21, 2026 00:01
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 21, 2026

🚀 Cloudflare Workers Preview has been successfully deployed!

Preview URL: https://md-pr-1563.doocs.workers.dev

Built with commit 0b581f0

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.createComment calls.

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.

Comment on lines 45 to +65
- 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 -->`
});
Comment on lines +58 to +64
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 -->`
Comment on lines +80 to +84
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 -->`
Comment on lines +120 to +124
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 -->`
Comment on lines 63 to +83
- 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 -->`
});
Comment on lines +76 to +82
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 -->`
@yanglbme yanglbme force-pushed the chore/replace-maintain-one-comment branch from 8a53c79 to 1eb45c4 Compare May 21, 2026 00:06
@yanglbme
Copy link
Copy Markdown
Member Author

@copilot 重新 review

Copy link
Copy Markdown
Contributor

Copilot AI commented May 21, 2026

@copilot 重新 review

Both issues raised in the original review have been addressed in commit 1eb45c4:

  1. Single-comment upsert behavior: All 3 Surge steps and the Cloudflare step now list existing PR comments, find one containing the HTML marker (<!-- Surge Preview Comment --> / <!-- Cloudflare Preview Comment -->), call updateComment if found, and only createComment otherwise — exactly matching the old maintain-one-comment behavior.

  2. Markdown formatting: All comment bodies are built with ['line1', '', 'line2', ...].join('\n') arrays instead of indented template literals, so no leading spaces are injected into the rendered Markdown.

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>
@yanglbme yanglbme force-pushed the chore/replace-maintain-one-comment branch from 1eb45c4 to 0b581f0 Compare May 21, 2026 00:18
@yanglbme yanglbme merged commit 90b03cb into main May 21, 2026
2 checks passed
@github-actions
Copy link
Copy Markdown

🗑️ Cloudflare Workers preview deployment has been cleaned up.

@yanglbme yanglbme deleted the chore/replace-maintain-one-comment branch May 21, 2026 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants