diff --git a/.github/workflows/deploy-preview.yml b/.github/workflows/deploy-preview.yml index 4b7fb88..f0a6c6e 100644 --- a/.github/workflows/deploy-preview.yml +++ b/.github/workflows/deploy-preview.yml @@ -48,21 +48,22 @@ jobs: directory: build gitHubToken: ${{ secrets.GITHUB_TOKEN }} # GitHub Deployments wranglerVersion: "3" - - name: "Comment on PR" - uses: actions/github-script@v6 + - name: Find PR number + id: find_pr_number + run: | + echo "pr_number=$(cat ./build/PR_NR)" >> $GITHUB_OUTPUT + - name: Find comment + uses: peter-evans/find-comment@v2 + id: find_comment with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const fs = require('fs'); - try { - const issue_number = Number(fs.readFileSync('./build/PR_NR')); - await github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: issue_number, - body: "Preview URL: ${{ steps.deploy.outputs.alias }}" - }); - } catch (err) { - console.log(err); - process.exit(1); - } + issue-number: ${{ steps.find_pr_number.outputs.pr_number }} + comment-author: "github-actions[bot]" + body-includes: "Preview URL:" + - name: Create or update comment + uses: peter-evans/create-or-update-comment@v3 + with: + comment-id: ${{ steps.find_comment.outputs.comment-id }} + issue-number: ${{ steps.find_pr_number.outputs.pr_number }} + body: | + Preview URL: ${{ steps.deploy.outputs.alias }} :rocket: + edit-mode: replace