|
| 1 | +name: Update docs data |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + release: |
| 6 | + types: [published] |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + pages: write |
| 11 | + id-token: write |
| 12 | + |
| 13 | +jobs: |
| 14 | + update-docs-data: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - name: Check out the current code |
| 18 | + uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + persist-credentials: true |
| 21 | + |
| 22 | + - name: Set up Node.js |
| 23 | + uses: actions/setup-node@v4 |
| 24 | + with: |
| 25 | + node-version: 18 |
| 26 | + cache: "npm" |
| 27 | + |
| 28 | + - name: Cache npm dependencies |
| 29 | + uses: actions/cache@v4 |
| 30 | + with: |
| 31 | + path: ~/.npm |
| 32 | + key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} |
| 33 | + restore-keys: | |
| 34 | + ${{ runner.os }}-npm- |
| 35 | +
|
| 36 | + - name: Write current date to environment variable |
| 37 | + run: echo "DATE=$(date +'%Y-%m-%d-%I.%M.%S%p')" >> $GITHUB_ENV |
| 38 | + |
| 39 | + - name: Add git user configuration |
| 40 | + run: | |
| 41 | + git config --local user.email "[email protected]" |
| 42 | + git config --local user.name "GitHub Action" |
| 43 | +
|
| 44 | + - name: Install dependencies |
| 45 | + run: npm ci --legacy-peer-deps |
| 46 | + |
| 47 | + - name: Fetch newest Automat OpenAPI document and metadata |
| 48 | + run: npm run preprocess |
| 49 | + |
| 50 | + - name: Remove the old markdown pages and regen with new OpenAPI data |
| 51 | + run: | |
| 52 | + npm run clean-api-docs automat |
| 53 | + npm run gen-api-docs automat |
| 54 | +
|
| 55 | + - name: Reorder sidebar listing to put TRAPI endpoints first |
| 56 | + run: npm run rearrange-sidebar |
| 57 | + |
| 58 | + - name: Group endpoints into query + metadata sections |
| 59 | + run: npm run rewrite-mdx |
| 60 | + |
| 61 | + - name: Remove "Introduction" page |
| 62 | + run: rm ./docs/automat/automat.info.mdx || echo "Introduction docs page is already deleted" |
| 63 | + |
| 64 | + - name: Check for untracked files |
| 65 | + run: | |
| 66 | + git add -A |
| 67 | + if git diff --cached --quiet; then |
| 68 | + echo "Docs have not been updated, nothing has changed." > $GITHUB_STEP_SUMMARY |
| 69 | + else |
| 70 | + echo "UPDATED=true" >> $GITHUB_ENV |
| 71 | + fi |
| 72 | +
|
| 73 | + # Only run the next two steps if there were changes detected by `git status` in the previous step |
| 74 | + - name: Commit changes |
| 75 | + if: ${{ env.UPDATED == 'true' }} |
| 76 | + run: | |
| 77 | + git commit -m "Update documentation - ${{ env.DATE }} [skip-ci]" |
| 78 | + git push |
| 79 | + env: |
| 80 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments