forked from midnightntwrk/midnight-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
275 lines (251 loc) · 10.4 KB
/
apis.yml
File metadata and controls
275 lines (251 loc) · 10.4 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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
name: Copy API docs
on:
workflow_dispatch:
inputs:
branch_merge:
description: 'Destination branch for merge'
default: 'main'
component:
description: 'Component docs to update'
type: choice
options:
- compactc
- dapp-connector
- midnight-indexer
- ledger
- midnight-js
- testkit-js
- wallet
- onchain-runtime
branch_compactc:
description: 'Compactc branch'
default: 'testnet'
branch_dapp_connector:
description: 'DApp Connector branch'
default: 'main'
branch_midnight_js:
description: 'Midnight JS branch'
default: 'main'
branch_ledger:
description: 'Ledger branch'
default: 'ledger-7.0.0'
branch_indexer:
description: 'Midnight Indexer branch'
default: 'v3.0.0'
branch_wallet:
description: 'Wallet branch'
default: 'main'
branch_testkit_js:
description: 'Testkit JS branch'
default: 'main'
branch_onchain_runtime:
description: 'Onchain Runtime branch'
default: 'onchain-runtime-2.0.1'
permissions:
contents: write
pull-requests: write
jobs:
copy_api_docs:
runs-on: ubuntu-latest
steps:
- name: Checkout docs repository specific branch
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # 6.0.1
with:
path: ${{ github.workspace }}
ref: ${{ github.event.inputs.branch_merge }}
- name: Git config
run: |
git config --global user.email "midnight-ci@users.noreply.github.com"
git config --global user.name "Midnight CI GitHub Action"
git config --global url.https://${{ secrets.GH_TOKEN }}@github.com/.insteadOf https://github.com/
- name: Clone compactc repo
if: ${{ github.event.inputs.component == 'compactc' }}
run: |
mkdir ./temp
cd temp
git clone --branch ${{ github.event.inputs.branch_compactc }} https://github.com/midnightntwrk/compactc.git
- name: Clone ledger repo
if: ${{ github.event.inputs.component == 'ledger' }}
run: |
mkdir ./temp
cd temp
git clone --branch ${{ github.event.inputs.branch_ledger }} https://github.com/midnightntwrk/midnight-ledger.git
- name: Update compact-runtime
if: ${{ github.event.inputs.component == 'compactc' }}
run: |
DEST_DIR=api-reference/compact-runtime
SRC_DIR=temp/compactc/doc/api/runtime
rm -rf ${DEST_DIR} || true
mkdir ${DEST_DIR}
cp -r ${SRC_DIR}/* ${DEST_DIR}
echo -e "# Compact runtime API\n\n$(cat ${DEST_DIR}/README.md)" > ${DEST_DIR}/README.md
- name: Update DApp connector
if: ${{ github.event.inputs.component == 'dapp-connector' }}
run: |
mkdir ./temp
cd temp
git clone --branch ${{ github.event.inputs.branch_dapp_connector }} https://github.com/midnightntwrk/midnight-dapp-connector-api.git
cd ..
DEST_DIR=api-reference/dapp-connector
SRC_DIR=temp/midnight-dapp-connector-api/docs/api
# Backup existing README if it exists
if [ -f ${DEST_DIR}/README.md ]; then
cp ${DEST_DIR}/README.md ./temp/backup-readme.md
fi
rm -rf ${DEST_DIR} || true
mkdir ${DEST_DIR}
cp -r ${SRC_DIR}/* ${DEST_DIR}
rm -f ${DEST_DIR}/README.md
# Restore backed up README if it existed
if [ -f ./temp/backup-readme.md ]; then
cp ./temp/backup-readme.md ${DEST_DIR}/README.md
fi
- name: Update ledger
if: ${{ github.event.inputs.component == 'ledger' }}
run: |
DEST_DIR=api-reference/ledger
SRC_DIR=temp/midnight-ledger/docs/api/ledger
rm -rf ${DEST_DIR} || true
mkdir ${DEST_DIR}
cp -r ${SRC_DIR}/* ${DEST_DIR}
echo -e "# Ledger API\n\n$(cat ${DEST_DIR}/README.md)" > ${DEST_DIR}/README.md
- name: Update midnight-js
if: ${{ github.event.inputs.component == 'midnight-js' }}
run: |
mkdir ./temp
cd temp
git clone --branch ${{ github.event.inputs.branch_midnight_js }} https://github.com/midnightntwrk/midnight-js.git
cd ..
DEST_DIR=api-reference/midnight-js
SRC_DIR=temp/midnight-js/docs/api/midnight-js
rm -rf ${DEST_DIR} || true
mkdir ${DEST_DIR}
cp -r ${SRC_DIR}/* ${DEST_DIR}
echo -e "# Midnight JS API\n\n$(cat ${DEST_DIR}/README.md)" > ${DEST_DIR}/README.md
- name: Update testkit-js
if: ${{ github.event.inputs.component == 'testkit-js' }}
run: |
mkdir ./temp
cd temp
git clone --branch ${{ github.event.inputs.branch_midnight_js }} https://github.com/midnightntwrk/midnight-js.git
cd ..
DEST_DIR=api-reference/testkit-js
SRC_DIR=temp/midnight-js/docs/api/testkit-js
rm -rf ${DEST_DIR} || true
mkdir ${DEST_DIR}
cp -r ${SRC_DIR}/* ${DEST_DIR}
echo -e "# Testkit JS API\n\n$(cat ${DEST_DIR}/README.md)" > ${DEST_DIR}/README.md
- name: Update midnight-indexer
if: ${{ github.event.inputs.component == 'midnight-indexer' }}
run: |
mkdir ./temp
cd temp
git clone --branch ${{ github.event.inputs.branch_indexer }} https://github.com/midnightntwrk/midnight-indexer.git
cd ..
DEST_DIR=api-reference/midnight-indexer
SRC_DIR=temp/midnight-indexer/docs/api/v3
STATIC_DIR=static/midnight-indexer
rm -rf ${DEST_DIR} || true
mkdir ${DEST_DIR}
cp -r ${SRC_DIR}/* ${DEST_DIR}
mv ${DEST_DIR}/api-documentation.md ${DEST_DIR}/README.md
sed -E -i 's|\[\`indexer-api/graphql/schema-v3\.graphql\`\]\(.*\)|[midnight-indexer-api-schema](pathname:///midnight-indexer/schema-v3.graphql)|g' ${DEST_DIR}/README.md
cp temp/midnight-indexer/indexer-api/graphql/schema-v3.graphql ${STATIC_DIR}
- name: Update wallet
if: ${{ github.event.inputs.component == 'wallet' }}
run: |
mkdir ./temp
cd temp
git clone --branch ${{ github.event.inputs.branch_wallet }} https://github.com/midnightntwrk/midnight-wallet.git
cd ..
DEST_DIR=static/midnight-wallet/snippets
SRC_DIR=temp/midnight-wallet/packages/docs-snippets/src/snippets
rm -rf ${DEST_DIR} || true
mkdir -p ${DEST_DIR}
cp -r ${SRC_DIR}/* ${DEST_DIR}
- name: Inject H1 header into midnight-js packages
if: ${{ github.event.inputs.component == 'midnight-js' }}
run: |
DEST_DIR=api-reference/midnight-js/@midnight-ntwrk
for d in ${DEST_DIR}/*/; do echo -e "# $(basename $d)\n\n$(cat $d/README.md)" > $d/README.md; done
- name: Update zswap
if: ${{ github.event.inputs.component == 'ledger' }}
run: |
DEST_DIR=api-reference/zswap
SRC_DIR=temp/midnight-ledger/docs/api/zswap
rm -rf ${DEST_DIR} || true
mkdir ${DEST_DIR}
cp -r ${SRC_DIR}/* ${DEST_DIR}
echo -e "# ZSwap API\n\n$(cat ${DEST_DIR}/README.md)" > ${DEST_DIR}/README.md
- name: Update onchain-runtime
if: ${{ github.event.inputs.component == 'onchain-runtime' }}
run: |
mkdir ./temp
cd temp
git clone --branch ${{ github.event.inputs.branch_onchain_runtime }} https://github.com/midnightntwrk/midnight-ledger.git
cd ..
DEST_DIR=api-reference/onchain-runtime
SRC_DIR=temp/midnight-ledger/docs/api/midnight-onchain-runtime
rm -rf ${DEST_DIR} || true
mkdir ${DEST_DIR}
cp -r ${SRC_DIR}/* ${DEST_DIR}
echo -e "# Onchain Runtime API\n\n$(cat ${DEST_DIR}/README.md)" > ${DEST_DIR}/README.md
- name: Update Compact standard library
if: ${{ github.event.inputs.component == 'compactc' }}
run: |
DEST_DIR=docs/compact/standard-library
SRC_DIR=temp/compactc/doc/api/CompactStandardLibrary
rm -rf ${DEST_DIR} || true
mkdir ${DEST_DIR}
cp -r ${SRC_DIR}/* ${DEST_DIR}
echo -e "# Compact standard library\n\n$(cat ${DEST_DIR}/README.md)" > ${DEST_DIR}/README.md
- name: Update static assets from compactc
if: ${{ github.event.inputs.component == 'compactc' }}
run: |
DEST_DIR=static/language
SRC_1=temp/compactc/doc/Compact.html
SRC_2=temp/compactc/doc/ledger-adt.mdx
rm -rf ${DEST_DIR} || true
mkdir ${DEST_DIR}
cp -r ${SRC_1} ${DEST_DIR}/compact.html
cp -r ${SRC_2} ${DEST_DIR}/ledger-adt.mdx
- name: Update compiler usage
if: ${{ github.event.inputs.component == 'compactc' }}
run: |
DEST=docs/compact/compilation-and-tooling/compiler-usage.mdx
SRC=temp/compactc/doc/compiler-usage.md
cp -r ${SRC} ${DEST}
- name: Add changes
id: prep
run: |
BRANCH=api-docs/merge-prs/`date +'%Y-%m-%dT%H%M%S'`
rm -rf ./temp
git checkout -b $BRANCH
if git diff-index HEAD; then
echo "NEW_BRANCH=$BRANCH" >> "$GITHUB_OUTPUT"
echo "UPDATE=true" >> "$GITHUB_OUTPUT"
echo "Adding new..."
git add -A
git push -u origin $BRANCH
else
echo "Nothing to update"
fi
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Add any untracked changes
if: ${{ steps.prep.outputs.UPDATE == 'true' }}
run: git add --all
- uses: planetscale/ghcommit-action@25309d8005ac7c3bcd61d3fe19b69e0fe47dbdde # v0.2.20
if: ${{ steps.prep.outputs.UPDATE == 'true' }}
with:
commit_message: "Copy API docs from other repositories"
repo: ${{ github.repository }}
branch: ${{ steps.prep.outputs.NEW_BRANCH }}
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Create a PR
if: ${{ steps.prep.outputs.UPDATE == 'true' }}
run: |
gh pr create --base ${{ github.event.inputs.branch_merge }} --title 'Merge API documentation from ${{ github.event.inputs.component }}' --body 'Merging API documentation - created by Midnight CI Github Action'
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}