-
Notifications
You must be signed in to change notification settings - Fork 48
224 lines (210 loc) · 8.33 KB
/
publish-site-prod.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
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
222
223
224
name: "Prod Site"
on:
workflow_dispatch:
push:
branches: [ "main" ]
permissions:
id-token: write
contents: read
jobs:
build:
runs-on: ubuntu-latest
environment: prod
steps:
# Clone current repo
- name: Checkout
uses: actions/checkout@v3
with:
path: src
# ref: develop # <-- required to deploy beta docs
# npm install
- name: npm install
working-directory: ./src
run: |
npm install
# compress the images
- name: Compress Images
working-directory: ./src
run: |
node ./scripts/compress.js ./
# Clone all the Meadow dependencies adjacent for DocFX build use.
- name: Checkout Meadow.Units side-by-side
uses: actions/checkout@v3
with:
repository: WildernessLabs/Meadow.Units
path: Meadow.Units
ref: main
- name: Checkout Meadow.Logging side-by-side
uses: actions/checkout@v3
with:
repository: WildernessLabs/Meadow.Logging
path: Meadow.Logging
ref: main
- name: Checkout Meadow.Contracts side-by-side
uses: actions/checkout@v3
with:
repository: WildernessLabs/Meadow.Contracts
path: Meadow.Contracts
ref: main
- name: Checkout Meadow.Modbus side-by-side
uses: actions/checkout@v3
with:
repository: WildernessLabs/Meadow.Modbus
path: Meadow.Modbus
ref: main
- name: Checkout Meadow.Foundation side-by-side
uses: actions/checkout@v3
with:
repository: WildernessLabs/Meadow.Foundation
path: Meadow.Foundation
ref: main
- name: Checkout Meadow.Core side-by-side
uses: actions/checkout@v3
with:
repository: WildernessLabs/Meadow.Core
path: Meadow.Core
ref: main
- name: Checkout MQTTnet side-by-side
uses: actions/checkout@v3
with:
repository: WildernessLabs/MQTTnet
path: MQTTnet
ref: master
- name: Checkout Meadow side-by-side
uses: actions/checkout@v3
with:
# Private repo requires token access; rest are public repos.
token: ${{ secrets.CI_ACCESS_TOKEN }}
repository: WildernessLabs/Meadow
path: Meadow
ref: main
# Clone more Meadow-related repos for API docs generation (via DocFX).
- name: Checkout Meadow.Foundation.CompositeDevices into DocFX-expected Source location
uses: actions/checkout@v3
with:
repository: WildernessLabs/Meadow.Foundation.CompositeDevices
path: Meadow.Foundation.CompositeDevices
ref: main
- name: Checkout Meadow.Foundation.Grove into DocFX-expected Source location
uses: actions/checkout@v3
with:
repository: WildernessLabs/Meadow.Foundation.Grove
path: Meadow.Foundation.Grove
ref: main
- name: Checkout Meadow.Foundation.FeatherWings into DocFX-expected Source location
uses: actions/checkout@v3
with:
repository: WildernessLabs/Meadow.Foundation.FeatherWings
path: Meadow.Foundation.FeatherWings
ref: main
- name: Checkout Meadow.Foundation.mikroBUS into DocFX-expected Source location
uses: actions/checkout@v3
with:
repository: WildernessLabs/Meadow.Foundation.mikroBUS
path: Meadow.Foundation.mikroBUS
ref: main
# # Set up for DocFX
- name: Setup .NET Core SDK 7.0.x
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
7.0.x
- name: Setup NuGet
uses: Nuget/[email protected]
- name: Install DocFX globally
run: |
dotnet tool install --global docfx
- name: Install DocFxMarkdownGen
run: |
dotnet tool install --global DocFxMarkdownGen
- name: Run DocFX
working-directory: ./src/docfx
run: |
docfx docfx.json
- name: Run DocFxMarkdownGen (dfmg) to generate API .md files for Meadow
# dfmg uses config.yaml for input/output paths
# Currently config has to be limited to `docfx/api/Meadow`, which means we need to figure out a way to run it for all the other /api directories.
# We might be able to set `env:DFMG_YAML_PATH` and `env:DFMG_OUTPUT_PATH` to the correct values for each repo, to generate them all before merging them together.
# One option is setting `env: {whatever}` via Actions syntax (https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_iddefaultsrun).
working-directory: ./src/docfx/dfmg/Meadow
run: |
dfmg
- name: Run DocFxMarkdownGen (dfmg) to generate API .md files for Meadow.Foundation
working-directory: ./src/docfx/dfmg/Meadow.Foundation
run: |
dfmg
- name: Run DocFxMarkdownGen (dfmg) to generate API .md files for Meadow.Foundation.CompositeDevices
working-directory: ./src/docfx/dfmg/Meadow.Foundation.CompositeDevices
run: |
dfmg
- name: Run DocFxMarkdownGen (dfmg) to generate API .md files for Meadow.Foundation.FeatherWings
working-directory: ./src/docfx/dfmg/Meadow.Foundation.FeatherWings
run: |
dfmg
- name: Run DocFxMarkdownGen (dfmg) to generate API .md files for Meadow.Foundation.Grove
working-directory: ./src/docfx/dfmg/Meadow.Foundation.Grove
run: |
dfmg
- name: Run DocFxMarkdownGen (dfmg) to generate API .md files for Meadow.Foundation.mikroBUS
working-directory: ./src/docfx/dfmg/Meadow.Foundation.mikroBUS
run: |
dfmg
# let's add correct slugs. They are important, because things won't build if they dont have "slug: /docs/api/..."
- name: Update slugs in frontmatter.
working-directory: ./src
run: |
node ./scripts/update-frontmatter.js
# Now we need to take all of the generated class/api reference documentation, and merge
# it into the api-overrides content
- name: Merge api docs together
working-directory: ./src
run: |
node ./scripts/merge-api-overrides.js Meadow.Foundation &&
node ./scripts/merge-api-overrides.js Meadow.Foundation.FeatherWings &&
node ./scripts/merge-api-overrides.js Meadow.Foundation.Grove &&
node ./scripts/merge-api-overrides.js Meadow.Foundation.mikroBUS
# Let's put the api files where they belong
- name: Copy api files to content locations
working-directory: ./src
run: |
node ./scripts/update-frontmatter.js &&
node ./scripts/copy-api.js
# Fun. Docusaurus isn't resolving the links correctly from many
# of the files output from dfmg. This script should help with that.
- name: Fix api broken links
working-directory: ./src
run: |
node ./scripts/api-broken-link-fixer.js ./docs/api/
# - name: Fix Meadow.Foundation periphs broken links
# working-directory: ./src
# run: |
# node ./scripts/meadow-foundation-broken-link-fixer.js
#docusaurus build
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
# Tell Node.js to look for the package-lock.json file in the cloned repo location rather than root.
cache-dependency-path: src/package-lock.json
- name: Docusaurus Build and Deploy
working-directory: ./src
run: |
npm run build
- uses: bacongobbler/azure-blob-storage-upload@main
with:
source_dir: './src/build'
container_name: '$web'
connection_string: ${{ secrets.BLOB_CONNECTIONSTRING }}
overwrite: 'true'
#sync: 'true'
# Purge Azure Front Door Cache
- name: Log into Azure
uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Purge Cache
run: |
az afd endpoint purge -g ${{ vars.RESOURCE_GROUP }} --profile-name ${{ vars.AFD_PROFILE_NAME }} --domains ${{ vars.AFD_DOMAINS }} --content-paths '/*' --endpoint-name ${{ vars.AFD_ENDPOINT_NAME }}