@@ -33,30 +33,38 @@ jobs:
3333 run-id : ${{ github.event.workflow_run.id }}
3434 - run : ls -R
3535 - name : Extract pull request number
36+ id : pr-number
3637 run : |
3738 PR_NUMBER=$(cat __metadata__pull_number.txt)
38- echo "PR_NUMBER =$PR_NUMBER" >> $GITHUB_ENV
39+ echo "value =$PR_NUMBER" >> $GITHUB_OUTPUT
3940 - name : Extract commit hash
41+ id : commit-hash
4042 run : |
4143 COMMIT_HASH=$(cat __metadata__commit_hash.txt)
42- echo "COMMIT_HASH =$COMMIT_HASH" >> $GITHUB_ENV
43- - run : echo $PR_NUMBER $COMMIT_HASH
44+ echo "value =$COMMIT_HASH" >> $GITHUB_OUTPUT
45+ - run : echo ${{ steps.pr-number.outputs.value }} ${{ steps.commit-hash.outputs.value }}
4446 - name : Deploy to cloudflare pages
4547 run : npx wrangler pages deploy ./ --project-name $CLOUDFLARE_PAGES_PROJECT --branch pr-$PR_NUMBER --commit-hash $COMMIT_HASH
4648 env :
49+ PR_NUMBER : ${{ steps.pr-number.outputs.value }}
50+ COMMIT_HASH : ${{ steps.commit-hash.outputs.value }}
4751 CLOUDFLARE_API_TOKEN : ${{ secrets.CLOUDFLARE_API_TOKEN }}
4852 CLOUDFLARE_ACCOUNT_ID : ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
4953 CLOUDFLARE_PAGES_PROJECT : ${{ vars.CLOUDFLARE_PAGES_PROJECT }}
54+ - name : Find Comment
55+ uses : peter-evans/find-comment@v3
56+ id : find-comment
57+ with :
58+ token : ${{ secrets.GITHUB_TOKEN }}
59+ issue-number : ${{ steps.pr-number.outputs.value }}
60+ comment-author : ' github-actions[bot]'
61+ body-includes : ' Preview deployed'
5062 - name : Comment on pull request
51- uses : actions/github-script @v4
63+ uses : peter-evans/create-or-update-comment @v4
5264 with :
53- github-token : ${{ secrets.GITHUB_TOKEN }}
54- script : |
55- const prNumber = process.env.PR_NUMBER;
56- github.issues.createComment({
57- issue_number: Number(prNumber),
58- owner: context.repo.owner,
59- repo: context.repo.repo,
60- body: `Preview deployed to https://pr-${prNumber}.dev-angular-jp.pages.dev`
61- })
65+ token : ${{ secrets.GITHUB_TOKEN }}
66+ comment-id : ${{ steps.find-comment.outputs.comment-id }}
67+ edit-mode : replace
68+ body : |
69+ Preview deployed to https://pr-${{ steps.pr-number.outputs.value }}.dev-angular-jp.pages.dev (commit: ${{ steps.commit-hash.outputs.value }})
6270
0 commit comments