Skip to content

Commit b79f58d

Browse files
authored
Merge pull request #681 from Koroeskohr/comment-on-pr
Add preview URL to pull request on preview
2 parents 2aa4bc9 + 1494671 commit b79f58d

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

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

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

1214
env:
1315
CLOUDFLARE_PAGES_PROJECT_NAME: typelevel-website
@@ -36,11 +38,26 @@ jobs:
3638
github-token: ${{ secrets.GITHUB_TOKEN }}
3739
- name: Read PR number
3840
id: pr
39-
run: echo "branch=pr-$(cat pr_number.txt)" >> "$GITHUB_OUTPUT"
41+
run: |
42+
echo "pr=$(cat pr_number.txt)" >> "$GITHUB_OUTPUT"
43+
echo "branch=pr-$(cat pr_number.txt)" >> "$GITHUB_OUTPUT"
44+
4045
- name: Deploy
4146
uses: cloudflare/wrangler-action@v4
47+
id: deploy
4248
with:
4349
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
4450
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
4551
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
4652
command: pages deploy ./site --project-name=${{ env.CLOUDFLARE_PAGES_PROJECT_NAME }} --branch=${{ steps.pr.outputs.branch }}
53+
- name: Add branch preview info to PR
54+
uses: marocchino/sticky-pull-request-comment@v3
55+
with:
56+
number: ${{ steps.pr.outputs.pr }}
57+
header: preview
58+
message: |
59+
# Branch preview
60+
61+
A preview of the website generated with the content of this pull request is available at this URL:
62+
63+
${{ steps.deploy.outputs.pages-deployment-alias-url }}

0 commit comments

Comments
 (0)