@@ -61,47 +61,31 @@ jobs:
6161 echo "Preview URL: $PREVIEW_URL"
6262
6363 - name : Comment PR with preview link
64- uses : actions/github-script@v7
64+ uses : actions-cool/maintain-one-comment@v3
6565 with :
66- github-token : ${{ secrets.GITHUB_TOKEN }}
67- script : |
68- const previewUrl = '${{ steps.deployment-url.outputs.url }}';
69- const prNumber = context.issue.number;
70-
71- // Find existing comment
72- const comments = await github.rest.issues.listComments({
73- owner: context.repo.owner,
74- repo: context.repo.repo,
75- issue_number: prNumber,
76- });
77-
78- const botComment = comments.data.find(comment =>
79- comment.user.type === 'Bot' &&
80- comment.body.includes('Cloudflare Workers Preview')
81- );
82-
83- const commentBody = `## 🚀 Cloudflare Workers Preview
84-
85- Your preview is ready!
86-
87- **Preview URL:** ${previewUrl}
88-
89- <sub>Built with commit ${context.sha}</sub>`;
90-
91- if (botComment) {
92- // Update existing comment
93- await github.rest.issues.updateComment({
94- owner: context.repo.owner,
95- repo: context.repo.repo,
96- comment_id: botComment.id,
97- body: commentBody
98- });
99- } else {
100- // Create new comment
101- await github.rest.issues.createComment({
102- owner: context.repo.owner,
103- repo: context.repo.repo,
104- issue_number: prNumber,
105- body: commentBody
106- });
107- }
66+ token : ${{ secrets.GITHUB_TOKEN }}
67+ body : |
68+ 🚀 Cloudflare Workers Preview has been successfully deployed!
69+
70+ **Preview URL:** ${{ steps.deployment-url.outputs.url }}
71+
72+ <sub>Built with commit ${{ github.event.pull_request.head.sha }}</sub>
73+
74+ <!-- Cloudflare Preview Comment -->
75+ body-include : ' <!-- Cloudflare Preview Comment -->'
76+ number : ${{ github.event.pull_request.number }}
77+
78+ - name : Deploy failed
79+ if : ${{ failure() }}
80+ uses : actions-cool/maintain-one-comment@v3
81+ with :
82+ token : ${{ secrets.GITHUB_TOKEN }}
83+ body : |
84+ 😭 Cloudflare Workers Preview deployment failed.
85+
86+ Please check the [workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details.
87+
88+ <!-- Cloudflare Preview Comment -->
89+ body-include : ' <!-- Cloudflare Preview Comment -->'
90+ number : ${{ github.event.pull_request.number }}
91+
0 commit comments