forked from MinBZK/mijn-bureau-infra
-
Notifications
You must be signed in to change notification settings - Fork 0
126 lines (109 loc) · 3.28 KB
/
deploy-docs.yaml
File metadata and controls
126 lines (109 loc) · 3.28 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: deploy-docs
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
pull_request:
branches:
- main
paths:
- "docs/**"
push:
branches:
- main
paths:
- "docs/**"
workflow_dispatch:
jobs:
build:
name: Build Docusaurus
runs-on: ubuntu-latest
defaults:
run:
working-directory: docs/
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- uses: actions/setup-node@v5
with:
node-version-file: "docs/.nvmrc"
cache: yarn
cache-dependency-path: docs/yarn.lock
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build website
run: yarn build
- name: Upload Build Artifact
uses: actions/upload-pages-artifact@v4
with:
path: docs/build
deploy-cloudflare-pages:
if: github.event_name == 'pull_request' && github.event.pull_request.draft == false
name: Deploy docs to Cloudflare Pages
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
defaults:
run:
working-directory: docs/
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- uses: actions/setup-node@v5
with:
node-version-file: "docs/.nvmrc"
cache: yarn
cache-dependency-path: docs/yarn.lock
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: replace baseUrl variables
run: |
sed -i 's|baseUrl: "/mijn-bureau-infra/"|baseUrl: "/"|g' docusaurus.config.ts
- name: Build website
run: yarn build
- name: install yarn for wrangler
run: npm install -g yarn
- name: Publish to Cloudflare Pages
id: wrangler
uses: cloudflare/wrangler-action@v3
if: github.event_name == 'pull_request'
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
workingDirectory: "docs"
command: versions upload
- name: Find Comment
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
body-includes: Docs Preview URL
- name: Comment on PR with Preview URL
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
edit-mode: replace
comment-id: ${{ steps.fc.outputs.comment-id }}
body: |
Docs Preview URL: ${{ steps.wrangler.outputs.deployment-url }}
deploy-github-pages:
if: github.event_name != 'pull_request'
name: Deploy docs to GitHub Pages
needs: build
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4