-
-
Notifications
You must be signed in to change notification settings - Fork 115
63 lines (56 loc) · 1.93 KB
/
Copy pathpr-preview-deploy.yml
File metadata and controls
63 lines (56 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: Deploy PR Preview
on:
workflow_run:
workflows: ["Continuous Integration"]
types: [completed]
permissions:
actions: read
contents: read
# Write sticky comment
pull-requests: write
env:
CLOUDFLARE_PAGES_PROJECT_NAME: typelevel-website
jobs:
deploy:
name: Publish to Cloudflare Pages
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
steps:
- name: Download site artifact
uses: actions/download-artifact@v4
with:
name: site
path: site
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Download PR number artifact
uses: actions/download-artifact@v4
with:
name: pr-number
path: .
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Read PR number
id: pr
run: |
echo "pr=$(cat pr_number.txt)" >> "$GITHUB_OUTPUT"
echo "branch=pr-$(cat pr_number.txt)" >> "$GITHUB_OUTPUT"
- name: Deploy
uses: cloudflare/wrangler-action@v4
id: deploy
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
command: pages deploy ./site --project-name=${{ env.CLOUDFLARE_PAGES_PROJECT_NAME }} --branch=${{ steps.pr.outputs.branch }}
- name: Add branch preview info to PR
uses: marocchino/sticky-pull-request-comment@v3
with:
number: ${{ steps.pr.outputs.pr }}
header: preview
message: |
# Branch preview
A preview of the website generated with the content of this pull request is available at this URL:
${{ steps.deploy.outputs.pages-deployment-alias-url }}