-
Notifications
You must be signed in to change notification settings - Fork 26
85 lines (81 loc) · 2.85 KB
/
docs_preview_deploy.yaml
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Docs Preview Deploy
on:
pull_request_target:
branches: [ main ]
paths:
- '.github/workflows/docs_preview_deploy.yaml'
- 'docs/**'
- 'samples/**'
jobs:
docs:
name: Deploy Docs
runs-on: ubuntu-latest
environment: docs-development
steps:
- uses: tibdex/github-app-token@v2
id: generate-token
with:
app_id: ${{ secrets.AUTO_MAID_APP_ID }}
private_key: ${{ secrets.AUTO_MAID_PRIVATE_KEY }}
- uses: actions/checkout@v4
with:
token: ${{ steps.generate-token.outputs.token }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
# Publish samples
- uses: subosito/flutter-action@v2.16.0
with:
flutter-version: 3.24.x
cache: true
- working-directory: ./samples
run: |
flutter pub get
flutter pub run build_runner build --delete-conflicting-outputs
flutter build web
- uses: cloudflare/pages-action@v1
id: publish-samples
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
projectName: ${{ vars.CLOUDFLARE_DEMO_PROJECT_NAME }}
directory: ./samples/build/web
# Publish docs
- uses: actions/setup-node@v4
with:
node-version: 20
- uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/configure-pages@v5
- working-directory: ./docs
run: |
pnpm install
NEXT_PUBLIC_DEMO_URL=${{ steps.publish-samples.outputs.url }} pnpm run export
- uses: cloudflare/pages-action@v1
id: publish-docs
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
projectName: ${{ vars.CLOUDFLARE_DOCS_PROJECT_NAME }}
branch: ${{ github.event.pull_request.head.ref }}
directory: ./docs/out
# Create/update comment with link to preview
- uses: peter-evans/find-comment@v3
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'auto-maid[bot]'
- uses: chuhlomin/render-template@v1.10
id: render-markdown
with:
template: .github/deployment_preview_template.md
vars: |
sha: ${{ github.event.pull_request.head.sha }}
url: ${{ steps.publish-docs.outputs.url }}
- uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ steps.generate-token.outputs.token }}
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: ${{ steps.render-markdown.outputs.result }}
edit-mode: replace