Skip to content

Commit 323dfdc

Browse files
committed
update workflows to automate deployment
1 parent 0e47440 commit 323dfdc

File tree

3 files changed

+109
-126
lines changed

3 files changed

+109
-126
lines changed
Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,41 @@
1-
name: "Build and push image to Github Container Registry"
1+
name: Build and push image to Github Container Registry
22

33
on:
4-
release:
5-
types: [published]
4+
workflow_run:
5+
workflows: ["Update docs data"] # This must exactly match the name: in update-docs-data.yml
6+
types:
7+
- completed
68

79
jobs:
8-
publish:
10+
docker-build-push:
911
name: Push Automat API docs to GHCR
1012
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
packages: write
16+
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'release' }}
17+
1118
steps:
1219
- name: Check out the repo
13-
uses: actions/checkout@v2
14-
- name: Get the version
15-
id: get_version
16-
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
17-
- name: Push api docs
18-
uses: docker/build-push-action@v1
20+
uses: actions/checkout@v4
21+
22+
- name: Log in to GHCR
23+
uses: docker/login-action@v3
1924
with:
2025
registry: ghcr.io
2126
username: ${{ github.actor }}
2227
password: ${{ secrets.GITHUB_TOKEN }}
23-
path: .
24-
dockerfile: ./Dockerfile
25-
repository: robokopu24/api-docs
26-
tags: latest,${{ steps.get_version.outputs.VERSION }}
28+
29+
- name: Extract release tag
30+
id: vars
31+
run: echo "TAG=${GITHUB_REF_NAME}" >> $GITHUB_ENV
32+
33+
- name: Build and push Docker image
34+
uses: docker/build-push-action@v5
35+
with:
36+
context: .
37+
file: ./Dockerfile
38+
push: true
39+
tags: |
40+
ghcr.io/${{ github.repository }}:${{ env.TAG }}
41+
ghcr.io/${{ github.repository }}:latest

.github/workflows/generate-docs.yml

Lines changed: 0 additions & 112 deletions
This file was deleted.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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

Comments
 (0)