-
-
Notifications
You must be signed in to change notification settings - Fork 9
229 lines (204 loc) · 6.68 KB
/
docs.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
225
226
227
228
229
---
name: Publish Catalog 📰
on:
workflow_call:
secrets:
REPO_GITHUB_TOKEN:
description: |
Github token with write access to the repository
required: false
GCHAT_WEBHOOK:
description: |
Google Chat webhook to send failure notifications
required: false
workflow_dispatch:
push:
branches:
- main
schedule:
- cron: "17 17 * * 3,6"
jobs:
cache-refresh:
name: Refresh Cache ♽
runs-on: ubuntu-latest
if: github.event_name == 'schedule'
steps:
- name: Refresh Cache ♽
run: |
gh extension install actions/gh-actions-cache
echo "Fetching list of cache keys..."
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 )
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do {
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
}
done
echo "Cache refresh completed."
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
BRANCH: ${{ github.event.repository.default_branch }}
publish-dev:
name: Build & Deploy TLGC (dev) 📖
runs-on: ubuntu-latest
container:
image: ghcr.io/insightsengineering/rstudio:latest
needs: cache-refresh
if: ${{ always() }}
permissions:
contents: write
steps:
- name: Checkout repo 🛎
uses: actions/[email protected]
- name: Cache artifacts 📀
uses: actions/cache@v4
with:
path: |
book/_freeze
key: ${{ runner.os }}-tlg-catalog-dev
- name: Normalize variables 📏
run: |
echo "gchat_webhook=${{ secrets.GCHAT_WEBHOOK }}" >> $GITHUB_ENV
shell: bash
- name: Setup R dependencies 🎦
uses: insightsengineering/setup-r-dependencies@v1
env:
GITHUB_PAT: ${{ steps.github-token.outputs.token }}
with:
repository-path: "./package"
skip-desc-branch: true
skip-desc-dev: true
repository-list: "r-universe-dev=https://pharmaverse.r-universe.dev/, PPM=PPM@latest"
cache-version: "dev"
- name: Render catalog 🖨
run: |
quarto render --profile development
shell: bash
working-directory: book
- name: Create artifact 📂
if: startsWith(github.ref, 'refs/tags/v')
run: |
zip -r9 ../../site.zip *
shell: bash
working-directory: book/_site
- name: Upload docs ⬆
if: startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-artifact@v4
with:
name: site-development
path: site.zip
- name: Publish docs 📔
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./book/_site
destination_dir: development
- name: GChat notification 🔔
if: (failure() || cancelled()) && env.gchat_webhook != ''
uses: insightsengineering/google-chat-notification@master
with:
name: ${{ github.event.repository.name }} - development
url: ${{ secrets.GCHAT_WEBHOOK }}
status: ${{ job.status }}
publish-stable:
name: Build & Deploy TLGC (stable) 📖
runs-on: ubuntu-latest
container:
image: ghcr.io/insightsengineering/rstudio:latest
permissions:
contents: write
needs:
- cache-refresh
if: ${{ always() }}
steps:
- name: Checkout repo 🛎
uses: actions/[email protected]
- name: Cache artifacts 📀
uses: actions/cache@v4
with:
path: |
book/_freeze
key: ${{ runner.os }}-tlg-catalog-stable
- name: Normalize variables 📏
run: |
echo "gchat_webhook=${{ secrets.GCHAT_WEBHOOK }}" >> $GITHUB_ENV
shell: bash
- name: Setup R dependencies 🎦
uses: insightsengineering/setup-r-dependencies@v1
env:
GITHUB_PAT: ${{ steps.github-token.outputs.token }}
with:
repository-path: "./package"
skip-desc-branch: true
skip-desc-dev: true
repository-list: "r-universe-stable=https://insightsengineering.r-universe.dev/, PPM=PPM@latest"
cache-version: "stable"
- name: Render catalog 🖨
run: |
quarto render --profile stable
shell: bash
working-directory: book
- name: Create artifact 📂
if: startsWith(github.ref, 'refs/tags/v')
run: |
zip -r9 ../../site.zip *
shell: bash
working-directory: book/_site
- name: Upload docs ⬆
if: startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-artifact@v4
with:
name: site-stable
path: site.zip
- name: Publish docs 📔
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./book/_site
destination_dir: stable
- name: GChat notification 🔔
if: (failure() || cancelled()) && env.gchat_webhook != ''
uses: insightsengineering/google-chat-notification@master
with:
name: ${{ github.event.repository.name }} - stable
url: ${{ secrets.GCHAT_WEBHOOK }}
status: ${{ job.status }}
upload-release-assets:
name: Upload assets 🔼
needs: [publish-dev, publish-stable]
runs-on: ubuntu-latest
if: >
startsWith(github.ref, 'refs/tags/v')
&& !contains(github.event.commits[0].message, '[skip docs]')
steps:
- name: Checkout repo 🛎
uses: actions/[email protected]
- name: Download artifact ⏬
uses: actions/download-artifact@v4
with:
name: site-development
path: site-development
- name: Download artifact ⏬
uses: actions/download-artifact@v4
with:
name: site-stable
path: site-stable
- name: Upload binaries to release ⤴
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: site-development/site.zip
asset_name: catalog-development.zip
tag: ${{ github.ref }}
overwrite: true
- name: Upload binaries to release ⤴
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: site-stable/site.zip
asset_name: catalog-stable.zip
tag: ${{ github.ref }}
overwrite: true