-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (76 loc) · 2.7 KB
/
update-docs-data.yml
File metadata and controls
93 lines (76 loc) · 2.7 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
name: Update docs data
on:
workflow_dispatch:
release:
types: [published]
permissions:
contents: write
pages: write
id-token: write
jobs:
update-docs-data:
runs-on: ubuntu-latest
steps:
- name: Check out the current code
uses: actions/checkout@v4
with:
ref: main
persist-credentials: true
- name: Pull latest changes
run: |
git pull origin main --rebase
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18
cache: "npm"
- name: Cache npm dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Write current date to environment variable
run: echo "DATE=$(date +'%Y-%m-%d-%I.%M.%S%p')" >> $GITHUB_ENV
- name: Add git user configuration
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
- name: Install dependencies
run: npm ci --legacy-peer-deps
- name: Fetch newest Automat OpenAPI document and metadata
run: npm run preprocess
- name: Remove the old markdown pages and regen with new OpenAPI data
run: |
npm run clean-api-docs automat
npm run gen-api-docs automat
- name: Reorder sidebar listing to put TRAPI endpoints first
run: npm run rearrange-sidebar
- name: Group endpoints into query + metadata sections
run: npm run rewrite-mdx
- name: Remove "Introduction" page
run: rm ./docs/automat/automat.info.mdx || echo "Introduction docs page is already deleted"
- name: Check for untracked files
run: |
git add -A
if git diff --cached --quiet; then
echo "Docs have not been updated, nothing has changed." > $GITHUB_STEP_SUMMARY
else
echo "UPDATED=true" >> $GITHUB_ENV
fi
# Only run the next two steps if there were changes detected by `git status` in the previous step
- name: Commit changes
if: ${{ env.UPDATED == 'true' }}
run: |
git commit -m "Update documentation - ${{ env.DATE }} [skip-ci]"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Trigger Docker build and push workflow
if: ${{ env.UPDATED == 'true' }}
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
event-type: build-push-docker
client-payload: '{"tag": "${{ github.event.release.tag_name }}"}'