-
-
Notifications
You must be signed in to change notification settings - Fork 5
186 lines (168 loc) · 6.78 KB
/
Copy pathdocs.yml
File metadata and controls
186 lines (168 loc) · 6.78 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
name: Docs
on:
push:
branches:
- main
paths:
- "docs/**"
- ".github/workflows/docs.yml"
- ".github/actions/install-hugo/action.yml"
pull_request:
types:
- opened
- reopened
- synchronize
- closed
paths:
- "docs/**"
- ".github/workflows/docs.yml"
- ".github/actions/install-hugo/action.yml"
# Fires for releases published by hand; releases created by the release
# workflow's GITHUB_TOKEN cannot trigger this event, so that workflow
# dispatches this one explicitly instead.
release:
types:
- published
workflow_dispatch:
# Publishing jobs raise this to write on themselves; keep the default read-only.
permissions:
contents: read
# One constant group serializes every docs run, so the deploy and preview
# jobs never push to the gh-pages branch concurrently; never cancel an
# in-progress deploy.
concurrency:
group: docs-gh-pages
cancel-in-progress: false
jobs:
# Production: build the site and publish it to the gh-pages branch root.
# Runs for a release (the release workflow dispatches it at the tag), a
# manual dispatch, or the merge of the release workflow's pin-update PR -
# the release tag predates that PR, so without this last deploy the root
# site would keep the previous release's wasm url/sha in its examples.
deploy:
name: "Deploy docs"
if: |
github.event_name == 'release' || github.event_name == 'workflow_dispatch' ||
(github.event_name == 'pull_request' &&
github.event.pull_request.merged == true &&
startsWith(github.event.pull_request.head.ref, 'release/update-readme-'))
runs-on: ubuntu-latest
# contents: write lets the deploy action push the built site to gh-pages.
permissions:
contents: write
steps:
# For the pin-update merge, build main (the released tag plus the pin
# commit) instead of the event's own ref; an empty ref is the default.
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
ref: ${{ github.event_name == 'pull_request' && 'main' || '' }}
- name: Install Hugo (extended)
uses: ./.github/actions/install-hugo
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7
with:
go-version-file: docs/go.mod
# baseURL comes from hugo.yaml (the production root).
- name: Build with Hugo
working-directory: docs
env:
HUGO_ENVIRONMENT: production
run: hugo --minify --gc
# clean-exclude keeps the preview trees so a production deploy never
# deletes main's preview or previews of still-open PRs; force: false
# rebases instead of force-pushing, tolerating concurrent preview pushes.
- name: Deploy to gh-pages
uses: JamesIves/github-pages-deploy-action@fa24774553152dd7873cd16ebd8d959b010c5445 # v4.9.0
with:
branch: gh-pages
folder: docs/public
clean-exclude: |
pr-preview/
preview/
force: false
# Main preview: every docs push to main deploys the current state under
# /preview/, leaving the root (latest release) untouched.
main-preview:
name: "Deploy main preview"
if: github.event_name == 'push'
runs-on: ubuntu-latest
# contents: write lets the deploy action push the built site to gh-pages.
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: Install Hugo (extended)
uses: ./.github/actions/install-hugo
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7
with:
go-version-file: docs/go.mod
# previewNoindex adds a robots noindex meta so the duplicate content
# under /preview/ never competes with the root site in search results.
- name: Build with Hugo
working-directory: docs
env:
HUGO_ENVIRONMENT: production
HUGO_PARAMS_PREVIEWNOINDEX: "true"
run: hugo --minify --gc --baseURL "https://sqlc-gen-better-python.rayakame.dev/preview/"
# target-folder scopes both the deploy and its cleaning to preview/,
# so the root site and the pr-preview umbrella are never touched.
- name: Deploy to gh-pages
uses: JamesIves/github-pages-deploy-action@fa24774553152dd7873cd16ebd8d959b010c5445 # v4.9.0
with:
branch: gh-pages
folder: docs/public
target-folder: preview
force: false
# PR previews: build with a per-PR baseURL and publish under
# gh-pages/pr-preview/pr-N; the action removes it when the PR closes.
preview:
name: "Deploy PR preview"
# Skip forks: their token is read-only, so a preview push would only fail.
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
# contents: write publishes the preview to gh-pages; pull-requests: write
# lets the action comment the preview URL on the pull request.
permissions:
contents: write
pull-requests: write
steps:
# Always checked out so the deploy action can operate, even on close.
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: Install Hugo (extended)
if: github.event.action != 'closed'
uses: ./.github/actions/install-hugo
- name: Set up Go
if: github.event.action != 'closed'
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7
with:
go-version-file: docs/go.mod
# The preview lives at <site>/pr-preview/pr-N/, so the absolute baseURL
# Hugo bakes into asset and link URLs must point at that subdirectory.
- name: Build with Hugo
if: github.event.action != 'closed'
working-directory: docs
env:
HUGO_ENVIRONMENT: production
HUGO_PARAMS_PREVIEWNOINDEX: "true"
PR_NUMBER: ${{ github.event.number }}
run: hugo --minify --gc --baseURL "https://sqlc-gen-better-python.rayakame.dev/pr-preview/pr-${PR_NUMBER}/"
- name: Deploy preview
uses: rossjrw/pr-preview-action@ffa7509e91a3ec8dfc2e5536c4d5c1acdf7a6de9 # v1.8.1
with:
source-dir: docs/public
preview-branch: gh-pages
umbrella-dir: pr-preview
# The PR comment's link defaults to <owner>.github.io/<repo>.
pages-base-url: sqlc-gen-better-python.rayakame.dev