-
Notifications
You must be signed in to change notification settings - Fork 43
63 lines (56 loc) · 2.04 KB
/
docs-pr-preview.yml
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 Docs Preview
on:
workflow_run:
workflows: ['CI']
branches: [master]
types: [completed]
pull_request:
branches: [master]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCS_CLOUDFLARE_DEPLOYMENT: true
jobs:
check:
name: Build and deploy Docs
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success' || github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
- run: pnpm install
- run: pnpm docs:build
- name: Deploy vitepress docs
id: deploy-docs
uses: cloudflare/wrangler-action@v3
with:
accountId: ${{ secrets.CF_ACCOUNT_ID || secrets.CLOUDFLARE_ACCOUNT_ID }}
apiToken: ${{ secrets.CF_API_TOKEN || secrets.CLOUDFLARE_API_TOKEN }}
packageManager: 'pnpm'
command: pages deploy docs/.vitepress/dist/ --project-name=cloudflare-turbo-cache-docs
- name: Comment with deploy link
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const deploymentUrl = process.env.DEPLOYMENT_URL;
const commitHash = context.payload.pull_request.head.sha;
const status = '✅ Deploy successful!'
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `
# 🌩 Deploying with Cloudflare Pages
| Name | Result |
| ----------------------- | ------ |
| **Last commit:** | \`${commitHash.substring(0, 7)}\` |
| **Status**: | ${status} |
| **Preview URL**: | ${deploymentUrl} |
`
});
env:
DEPLOYMENT_URL: ${{ steps.deploy-docs.outputs.deployment-url }}