Skip to content

Commit 0567c27

Browse files
committed
Add a sticky comment to a PR with the outcome of the preview
1 parent 9d026f0 commit 0567c27

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

.github/workflows/pr-preview-deploy.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ on:
88
permissions:
99
actions: read
1010
contents: read
11+
deployments: write
12+
# Write sticky comment
13+
pull-requests: write
1114

1215
env:
1316
CLOUDFLARE_PAGES_PROJECT_NAME: typelevel-website
@@ -36,11 +39,28 @@ jobs:
3639
github-token: ${{ secrets.GITHUB_TOKEN }}
3740
- name: Read PR number
3841
id: pr
39-
run: echo "branch=pr-$(cat pr_number.txt)" >> "$GITHUB_OUTPUT"
42+
run: |
43+
echo "pr=$(cat pr_number.txt)" >> "$GITHUB_OUTPUT"
44+
echo "branch=pr-$(cat pr_number.txt)" >> "$GITHUB_OUTPUT"
45+
4046
- name: Deploy
4147
uses: cloudflare/wrangler-action@v4
48+
id: deploy
4249
with:
4350
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
4451
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
4552
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
4653
command: pages deploy ./site --project-name=${{ env.CLOUDFLARE_PAGES_PROJECT_NAME }} --branch=${{ steps.pr.outputs.branch }}
54+
- name: Add branch preview info to PR
55+
uses: marocchino/sticky-pull-request-comment@v3
56+
with:
57+
number: ${{ steps.pr.outputs.pr }}
58+
header: preview
59+
message: |
60+
# Branch preview
61+
62+
A preview of the website has been generated with the content of this pull request.
63+
64+
| Name | Result |
65+
| ----------------------- | ------ |
66+
| **Branch Preview URL**: | ${{ steps.deploy.outputs.pages-deployment-alias-url }} |

0 commit comments

Comments
 (0)