-
Notifications
You must be signed in to change notification settings - Fork 11
75 lines (66 loc) · 2.73 KB
/
sync-docs.yml
File metadata and controls
75 lines (66 loc) · 2.73 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
name: Generate API Docs and PR to genlayer-docs
on:
workflow_dispatch:
release:
types: [published]
jobs:
generate-and-sync:
if: github.event_name != 'release' || !contains(github.event.release.tag_name, '-')
runs-on: ubuntu-latest
environment: Sync-docs
permissions:
contents: read
steps:
- name: Checkout SDK repo
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Determine version
id: version
run: |
if [ "${{ github.event_name }}" = "release" ]; then
echo "value=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT
else
echo "value=$(node -p 'require("./package.json").version')" >> $GITHUB_OUTPUT
fi
- name: Generate API docs
run: node scripts/generate-api-docs.mjs
- name: Generate docs repo token
id: app-token
uses: actions/create-github-app-token@v3
with:
client-id: ${{ vars.DOCS_SYNC_APP_CLIENT_ID }}
private-key: ${{ secrets.DOCS_SYNC_APP_KEY }}
repositories: genlayer-docs
- name: Checkout docs repo
uses: actions/checkout@v4
with:
repository: genlayerlabs/genlayer-docs
token: ${{ steps.app-token.outputs.token }}
path: docs-repo
fetch-depth: 0
- name: Sync and push docs
working-directory: docs-repo
run: |
set -euo pipefail
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
rm -rf pages/api-references/genlayer-js
mkdir -p pages/api-references/genlayer-js
cp "${{ github.workspace }}/docs/api-references/index.md" pages/api-references/genlayer-js.md
cp "${{ github.workspace }}/docs/api-references/contracts.md" pages/api-references/genlayer-js/contracts.md
cp "${{ github.workspace }}/docs/api-references/transactions.md" pages/api-references/genlayer-js/transactions.md
cp "${{ github.workspace }}/docs/api-references/staking.md" pages/api-references/genlayer-js/staking.md
printf '{\n "contracts": "Contracts",\n "transactions": "Transactions",\n "staking": "Staking"\n}\n' > pages/api-references/genlayer-js/_meta.json
if [ -z "$(git status --porcelain)" ]; then
echo "No changes to commit"
exit 0
fi
git add pages/api-references/genlayer-js pages/api-references/genlayer-js.md
git commit -m "docs(js): sync API reference ${{ steps.version.outputs.value }}"
git push