Skip to content

Commit 49ad5b9

Browse files
misc: Added Github Actions for linting and building api specs (#6720)
* Added action to check for linting errors in openapi.yaml * Create build-docs.yaml * added read-only permission in api-linter * updated action to add permission
1 parent 3310508 commit 49ad5b9

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

.github/workflows/api-linter.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Lint API Specs
2+
on:
3+
pull_request:
4+
paths:
5+
- 'specs/swagger/**'
6+
permissions:
7+
contents: read
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v4
18+
- name: Install Redocly CLI
19+
run: npm install -g @redocly/cli
20+
- name: Lint OpenAPI specification
21+
run: |
22+
cd specs/swagger
23+
echo "Linting OpenAPI specification..."
24+
redocly lint openapi.yaml
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GH_SYSTEMSDT_TOKEN }}

.github/workflows/build-docs.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: OpenAPI Build Documentation
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths:
7+
- 'specs/swagger/**'
8+
permissions:
9+
contents: write
10+
jobs:
11+
lint-and-build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
21+
- name: Install Redocly CLI
22+
run: npm install -g @redocly/cli
23+
24+
- name: Switch to gh-pages branch
25+
run: |
26+
git config --local user.email "[email protected]"
27+
git config --local user.name "GitHub Action"
28+
echo "Switching to gh-pages branch..."
29+
git checkout -b gh-pages
30+
git fetch origin gh-pages
31+
git pull --rebase origin gh-pages
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GH_SYSTEMSDT_TOKEN }}
34+
- name: Build OpenAPI documentation
35+
run: |
36+
cd specs/swagger
37+
echo "Building OpenAPI documentation..."
38+
redocly build-docs openapi.yaml --output=openapi.html
39+
echo "Documentation built successfully!"
40+
41+
- name: Commit and push documentation
42+
run: |
43+
git config --local user.email "[email protected]"
44+
git config --local user.name "GitHub Action"
45+
echo "Committing and pushing documentation..."
46+
git add specs/swagger/openapi.html
47+
if git diff --staged --quiet; then
48+
echo "No changes to commit"
49+
else
50+
git commit -m "Update OpenAPI documentation from main branch"
51+
git push --force origin gh-pages
52+
echo "Documentation pushed to gh-pages branch!"
53+
fi
54+
env:
55+
GITHUB_TOKEN: ${{ secrets.GH_SYSTEMSDT_TOKEN }}

0 commit comments

Comments
 (0)