-
Notifications
You must be signed in to change notification settings - Fork 4
221 lines (196 loc) · 8.62 KB
/
process_docs_changes.yml
File metadata and controls
221 lines (196 loc) · 8.62 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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
name: Process Docs Changes
on:
workflow_dispatch:
inputs:
source_branch:
description: metabase/metabase branch triggered this workflow
required: true
type: string
target_branch:
description: metabase/metabase target branch name
required: true
type: string
annotation:
description: note to describe what the pr does
required: false
type: string
default: "auto-build"
dispatch_type:
description: 'Type of dispatch action to simulate'
required: false
default: 'docs_update'
type: choice
options:
- docs_update
- docs_merge
- docs_close
pr_number:
description: 'Number of the PR in metabase/metabase that triggered this action'
required: false
type: number
update_dirs:
description: comma delimited paths to git add into the generated PR
required: false
type: string
default: ""
repository_dispatch:
types: [docs_update, docs_merge, docs_close]
run-name: >-
${{
(github.event.action == 'docs_merge' || github.event.inputs.dispatch_type == 'docs_merge') && '✅' ||
(github.event.action == 'docs_update' || github.event.inputs.dispatch_type == 'docs_update') && '🔄' ||
(github.event.action == 'docs_close' || github.event.inputs.dispatch_type == 'docs_close') && '🗑️'
}}${{
(github.event.inputs.annotation || github.event.client_payload.annotation) &&
format(' | `{0}` | ', github.event.inputs.annotation || github.event.client_payload.annotation) ||
' | '
}}`${{ github.event.inputs.source_branch || github.event.client_payload.source_branch }}` -> `${{ github.event.inputs.target_branch || github.event.client_payload.target_branch }}`
jobs:
build:
name: >-
`${{ github.event.inputs.source_branch || github.event.client_payload.source_branch }}` -> ${{ github.event.inputs.target_branch || github.event.client_payload.target_branch }} | ${{ github.event.action || github.event.inputs.dispatch_type }}
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.METABASE_AUTOMATION_USER_TOKEN }}
MAIN_REPO_SOURCE_BRANCH: "${{ github.event.inputs.source_branch || github.event.client_payload.source_branch }}"
MAIN_REPO_TARGET_BRANCH: "${{ github.event.inputs.target_branch || github.event.client_payload.target_branch }}"
ANNOTATION: "${{ github.event.inputs.annotation || github.event.client_payload.annotation || 'auto-build' }}"
PR_NUMBER: "${{ github.event.inputs.pr_number || github.event.client_payload.pr_number }}"
UPDATE_DIRS: "${{ github.event.inputs.update_dirs || github.event.client_payload.update_dirs }}"
steps:
- uses: actions/checkout@v4
- name: Prepare java
uses: actions/setup-java@v4
with:
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '21'
- name: Install Clojure (needed to build cljs for SDK dox generation)
uses: DeLaGuardo/setup-clojure@13.2
with:
cli: 1.12.0.1530
bb: 1.12.200
- name: Check for PR Close
id: check
if: |
(github.event_name == 'repository_dispatch' && github.event.action == 'docs_close') ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.dispatch_type == 'docs_close')
run: |
gh pr close "${MAIN_REPO_SOURCE_BRANCH}->${MAIN_REPO_TARGET_BRANCH}" --repo metabase/docs.metabase.github.io --delete-branch
echo "skip=true" >> "$GITHUB_OUTPUT"
- name: Run docs repo build tests
if: steps.check.outputs.skip != 'true'
run: |
bb script/_test/all.clj
- name: Filter non-documented branches
if: steps.check.outputs.skip != 'true'
run: |
bb script/check_incoming_branchname.clj --target-branch "$MAIN_REPO_TARGET_BRANCH"
- name: Setup Node.js
if: steps.check.outputs.skip != 'true'
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install js dependencies
if: steps.check.outputs.skip != 'true'
run: yarn install --frozen-lockfile --prefer-offline
- name: Set up Ruby # uses version from .ruby-version
if: steps.check.outputs.skip != 'true'
uses: ruby/setup-ruby@d5fb7a202fc07872cb44f00ba8e6197b70cb0c55 # v1.179.0
with:
bundler-cache: true
- name: Install ruby dependencies
if: steps.check.outputs.skip != 'true'
run: |
bundle install
- name: Setup Git Authenticatation
if: steps.check.outputs.skip != 'true'
run: |
git config --global user.name "Metabase Docs bot"
git config --global user.email "metabase-bot@metabase.com"
git remote set-url origin "https://x-access-token:${{ secrets.METABASE_AUTOMATION_USER_TOKEN }}@github.com/metabase/docs.metabase.github.io.git"
# observed this failing during sdk docs generation deps downloads, so adding retry logic
- name: Update docs for branchname
uses: nick-fields/retry@v3
if: |
(steps.check.outputs.skip != 'true' &&
((github.event_name == 'repository_dispatch' && github.event.action == 'docs_update') ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.dispatch_type == 'docs_update')))
with:
timeout_minutes: 20
max_attempts: 3
retry_on: error
command: |
bb script/update_docs_for_branchname.clj --source-branch "$MAIN_REPO_SOURCE_BRANCH" --target-branch "$MAIN_REPO_TARGET_BRANCH"
- name: Cleanup cloud docs (move them to latest, remove from all other versions)
if: steps.check.outputs.skip != 'true'
run: |
bb script/cleanup_cloud_docs.clj
- name: Checkout Control files from Marketing Repo
if: steps.check.outputs.skip != 'true'
uses: actions/checkout@v4
with:
repository: metabase/metabase.github.io
ref: master
path: .marketing_repo
token: ${{ secrets.METABASE_AUTOMATION_USER_TOKEN }}
- name: Merge control files from Marketing Repo
if: steps.check.outputs.skip != 'true'
run: |
bb script/sync_repo.clj --from-repo .marketing_repo
- name: "yarn lint-markdown"
if: steps.check.outputs.skip != 'true'
run: |
yarn lint-markdown
- name: "yarn lint-styles"
if: steps.check.outputs.skip != 'true'
run: |
yarn lint-styles
- name: "yarn lint-scripts"
if: steps.check.outputs.skip != 'true'
run: |
yarn lint-scripts
- name: "yarn lint-links"
if: steps.check.outputs.skip != 'true'
run: |
yarn lint-links
- name: Build the Jekyll Site
if: steps.check.outputs.skip != 'true'
env:
JEKYLL_ENV: production
NODE_ENV: production
run: |
# Clear the existing site:
rm -rf _site
# Build the jekyll site:
script/build
- name: Run htmlproofer + metabase.com-aware link checks
if: steps.check.outputs.skip != 'true'
run: |
SECONDS=0
script/links || true
echo "htmlproofer took: ${SECONDS} seconds."
echo 'checking reported links...'
echo "htmlproofer spit out a report of length: $(wc -l < htmlproofer.out)"
bb script/analyze_links.clj --htmlproofer-output htmlproofer.out --limit 1
- name: Update or Create the Pull Request
if: |
(steps.check.outputs.skip != 'true' &&
((github.event_name == 'repository_dispatch' && github.event.action == 'docs_update') ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.dispatch_type == 'docs_update')))
run: |
bb script/update_or_create_pr.clj \
--source-branch "$MAIN_REPO_SOURCE_BRANCH" \
--target-branch "$MAIN_REPO_TARGET_BRANCH" \
--annotation "$ANNOTATION" \
--pr-number "$PR_NUMBER" \
--update-dirs "$UPDATE_DIRS"
- name: Remove control files from Marketing Repo
run: |
bb script/sync_repo.clj --delete
- name: Merge Updated Docs
if: |
(steps.check.outputs.skip != 'true' &&
((github.event_name == 'repository_dispatch' && github.event.action == 'docs_merge') ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.dispatch_type == 'docs_merge')))
run: |
bb script/merge.clj --source-branch "$MAIN_REPO_SOURCE_BRANCH" --target-branch "$MAIN_REPO_TARGET_BRANCH"