-
Notifications
You must be signed in to change notification settings - Fork 5
177 lines (155 loc) · 5.79 KB
/
Copy pathdocs.yml
File metadata and controls
177 lines (155 loc) · 5.79 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
name: Build and Deploy Docusaurus with KDocs
on:
push:
branches:
- main
workflow_dispatch:
inputs:
build_kdocs:
description: 'Generate API reference KDocs with Dokka (disable for faster CI)'
type: boolean
default: true
repository_dispatch:
types: [multipaz-repo-updated, extras-repo-updated]
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: true
jobs:
build:
name: Build Docusaurus with KDocs
runs-on: ubuntu-latest
env:
# Whether to build the API reference KDocs ('true') or skip the slow Dokka
# generation ('false').
# - On a manual run, the "build_kdocs" checkbox is authoritative and overrides
# everything else (tick to build, untick to skip).
# - On automatic runs (push / repository_dispatch), KDocs are built unless the
# repository variable BUILD_KDOCS is set to 'false' (e.g. on a fork) to
# permanently skip them.
# build_kdocs is a boolean input, so it's matched against both the boolean and
# string forms to stay robust regardless of how the value is rendered.
BUILD_KDOCS: ${{ github.event_name == 'workflow_dispatch' && ((inputs.build_kdocs == true || inputs.build_kdocs == 'true') && 'true' || 'false') || (vars.BUILD_KDOCS == 'false' && 'false' || 'true') }}
steps:
- name: Checkout Docusaurus Repository
uses: actions/checkout@v4
with:
path: docusaurus-repo
- name: Checkout Multipaz Repository
uses: actions/checkout@v4
with:
repository: openwallet-foundation/multipaz
path: multipaz-repo
ref: 'main'
fetch-depth: 0
fetch-tags: true
- name: Get Multipaz Repo Commit Hash
id: multipaz-commit-hash
if: env.BUILD_KDOCS == 'true'
run: |
cd multipaz-repo
COMMIT_HASH=$(git rev-parse HEAD)
echo "commit_hash=$COMMIT_HASH" >> $GITHUB_OUTPUT
echo "Latest commit hash: $COMMIT_HASH"
- name: Cache Multipaz KDocs
id: cache-multipaz-kdocs
if: env.BUILD_KDOCS == 'true'
uses: actions/cache@v3
with:
path: multipaz-repo/build/dokka
key: kdocs-${{ steps.multipaz-commit-hash.outputs.commit_hash }}
- name: Checkout Multipaz Extras Repository
if: env.BUILD_KDOCS == 'true'
uses: actions/checkout@v4
with:
repository: openwallet-foundation/multipaz-extras
path: extras-repo
ref: 'main'
fetch-depth: 0
fetch-tags: true
- name: Get Extras Repo Commit Hash
id: extras-commit-hash
if: env.BUILD_KDOCS == 'true'
run: |
cd extras-repo
COMMIT_HASH=$(git rev-parse HEAD)
echo "commit_hash=$COMMIT_HASH" >> $GITHUB_OUTPUT
echo "Latest commit hash: $COMMIT_HASH"
- name: Cache Extras KDocs
id: cache-extras-kdocs
if: env.BUILD_KDOCS == 'true'
uses: actions/cache@v3
with:
path: extras-repo/build/dokka
key: kdocs-${{ steps.extras-commit-hash.outputs.commit_hash }}
- name: Set up JDK
if: env.BUILD_KDOCS == 'true'
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
cache: 'gradle'
- name: Generate Multipaz KDocs with Dokka
if: env.BUILD_KDOCS == 'true' && steps.cache-multipaz-kdocs.outputs.cache-hit != 'true'
run: |
cd multipaz-repo
./gradlew dokkaGenerate
echo "KDocs generated successfully"
- name: Generate Extras KDocs with Dokka
if: env.BUILD_KDOCS == 'true' && steps.cache-extras-kdocs.outputs.cache-hit != 'true'
run: |
cd extras-repo
./gradlew dokkaGenerate
echo "KDocs generated successfully"
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
cache-dependency-path: docusaurus-repo/package-lock.json
- name: Create API directories in Docusaurus static folder
if: env.BUILD_KDOCS == 'true'
run: |
mkdir -p docusaurus-repo/static/kdocs
mkdir -p docusaurus-repo/static/kdocs-extras
- name: Copy KDocs and markdown files to Docusaurus
run: ./docusaurus-repo/copy_docs.sh
- name: Install Docusaurus dependencies
run: |
cd docusaurus-repo
npm ci
- name: Build Docusaurus website
env:
NODE_ENV: production
ASK_AI_API_URL: ${{ vars.ASK_AI_API_URL }}
DOCUSAURUS_URL: https://${{ github.repository_owner }}.github.io
# Dynamic baseUrl: PRODUCTION uses /, otherwise uses /repository-name/
DOCUSAURUS_BASEURL: ${{ vars.WEBSITE_ENVIRONMENT == 'PRODUCTION' && '/' || format('/{0}/', github.event.repository.name) }}
run: |
cd docusaurus-repo
# Debug: Show the resolved baseUrl and environment
echo "Resolved DOCUSAURUS_BASEURL: $DOCUSAURUS_BASEURL"
echo "WEBSITE_ENVIRONMENT: ${{ vars.WEBSITE_ENVIRONMENT }}"
# Include the current date in the build for versioning
echo "Build date: $(date +'%Y-%m-%d %H:%M:%S')" > src/build-info.json
npm run build
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: docusaurus-repo/build
deploy:
name: Deploy to GitHub Pages
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4