Skip to content

Commit 41f0921

Browse files
Add Specs Render
Add the ability to render specification files to github pages.
1 parent dd00eed commit 41f0921

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Deploy Swagger UI Spec Docs
2+
3+
# Determine when to run this workflow
4+
on:
5+
# Allow manual triggering of the workflow
6+
workflow_dispatch:
7+
# Runs every Sunday at 00:00 UTC
8+
schedule:
9+
- cron: '0 0 * * 0'
10+
11+
jobs:
12+
Deploy-GH-Pages:
13+
# Human friendly display name for the job
14+
name: Deploy OpenAPI Specification to GitHub Pages
15+
16+
# Filter for which runners are allowed to execute this job
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
# Configure the GH pages environment
21+
- name: Setup Pages
22+
uses: actions/configure-pages@v5
23+
24+
# Grab a copy of the latest binaries
25+
- name: Download Latest Swagger UI Release
26+
run: |
27+
LATEST_URL=$(curl -sL https://api.github.com/repos/swagger-api/swagger-ui/releases/latest | grep "browser_download_url.*tar.gz" | cut -d '"' -f 4)
28+
curl -L "$LATEST_URL" -o swagger-ui.tar.gz
29+
30+
# Extract the downloaded archive
31+
- name: Extract Swagger UI dist folder
32+
run: |
33+
mkdir swagger-ui
34+
tar -xzf swagger-ui.tar.gz --strip-components=1 -C swagger-ui
35+
36+
# Update the config to have the SHI Lab Specs
37+
- name: Replace SwaggerUIBundle url with urls array in swagger-initializer.js
38+
run: |
39+
DIST_FILE="swagger-ui/dist/swagger-initializer.js"
40+
# Remove the 'url:' property and insert the 'urls:' array
41+
sed -i '/url: /c\ urls: [\n {\n "url": "https://raw.githubusercontent.com/Software-Hardware-Integration-Lab/OpenAPI/refs/heads/main/specs/Data-Gateway.json",\n "name": "Data Gateway"\n },\n {\n "url": "https://raw.githubusercontent.com/Software-Hardware-Integration-Lab/OpenAPI/refs/heads/main/specs/SHIELD.json",\n "name": "SHIELD"\n }\n ],' "$DIST_FILE"
42+
43+
# Uploads the built artifact to github pages
44+
- name: Upload Artifact
45+
uses: actions/upload-pages-artifact@v3
46+
with:
47+
# Upload static files
48+
path: "swagger-ui/dist/"
49+
50+
# Deploy the compiled pages
51+
- name: Deploy to GitHub Pages
52+
id: deployment
53+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)