@@ -3,73 +3,83 @@ name: Deploy API Documentation
33on :
44 push :
55 branches : [ main, feature/clean-up-repo ]
6- paths :
6+ paths :
77 - ' api/openapi.yaml'
8- - ' .github/workflows/docs.yml'
98 workflow_dispatch :
109
11- permissions :
12- contents : read
13- pages : write
14- id-token : write
15-
1610jobs :
17- build-docs :
18- name : Build API docs
11+ deploy-docs :
1912 runs-on : ubuntu-latest
13+ permissions :
14+ contents : read
15+ pages : write
16+ id-token : write
17+
2018 steps :
21- - name : Checkout repo
19+ - name : Checkout repository
2220 uses : actions/checkout@v4
23-
24- - name : Set up Node
25- uses : actions/setup-node@v4
26- with :
27- node-version : ' 20'
28- cache : ' npm'
29-
30- - name : Install doc generators
31- run : |
32- npm install --location=global redoc-cli swagger-ui-dist
33-
34- - name : Generate ReDoc HTML
21+
22+ - name : Setup Pages
23+ uses : actions/configure-pages@v4
24+
25+ - name : Create docs directory
26+ run : mkdir -p docs
27+
28+ - name : Copy OpenAPI spec
29+ run : cp api/openapi.yaml docs/openapi.yaml
30+
31+ - name : Create Swagger UI HTML
3532 run : |
36- redoc-cli bundle api/openapi.yaml -o docs/api.html
37-
38- - name : Build Swagger UI static site
39- run : |
40- SWAGGER_DIST=$(npm root -g)/swagger-ui-dist
41- mkdir -p docs/swagger
42- cp -R "$SWAGGER_DIST"/* docs/swagger/
43- # Copy spec next to the viewer
44- cp api/openapi.yaml docs/swagger/openapi.yaml
45- # Replace default initializer with one that loads our spec
46- cat > docs/swagger/swagger-initializer.js <<'EOF'
47- window.onload = function() {
48- window.ui = SwaggerUIBundle({
49- url: "openapi.yaml",
50- dom_id: '#swagger-ui',
51- presets: [
52- SwaggerUIBundle.presets.apis,
53- SwaggerUIBundle.SwaggerUIStandalonePreset
54- ],
55- layout: "BaseLayout"
56- });
57- };
33+ cat > docs/index.html << 'EOF'
34+ <!DOCTYPE html>
35+ <html>
36+ <head>
37+ <title>RecipAI API Documentation</title>
38+ <link rel="stylesheet" type="text/css" href="https://unpkg.com/swagger-ui-dist@5.9.0/swagger-ui.css" />
39+ <link rel="icon" type="image/png" href="https://unpkg.com/swagger-ui-dist@5.9.0/favicon-32x32.png" sizes="32x32" />
40+ <style>
41+ html { box-sizing: border-box; overflow: -moz-scrollbars-vertical; overflow-y: scroll; }
42+ *, *:before, *:after { box-sizing: inherit; }
43+ body { margin:0; background: #fafafa; }
44+ .info .title { color: #3b4151; font-size: 36px; }
45+ </style>
46+ </head>
47+ <body>
48+ <div id="swagger-ui"></div>
49+ <script src="https://unpkg.com/swagger-ui-dist@5.9.0/swagger-ui-bundle.js"></script>
50+ <script src="https://unpkg.com/swagger-ui-dist@5.9.0/swagger-ui-standalone-preset.js"></script>
51+ <script>
52+ window.onload = function() {
53+ const ui = SwaggerUIBundle({
54+ url: './openapi.yaml',
55+ dom_id: '#swagger-ui',
56+ deepLinking: true,
57+ presets: [
58+ SwaggerUIBundle.presets.apis,
59+ SwaggerUIStandalonePreset
60+ ],
61+ plugins: [
62+ SwaggerUIBundle.plugins.DownloadUrl
63+ ],
64+ layout: "StandaloneLayout",
65+ validatorUrl: null,
66+ tryItOutEnabled: true,
67+ supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
68+ onComplete: function() {
69+ console.log('Swagger UI loaded');
70+ }
71+ });
72+ };
73+ </script>
74+ </body>
75+ </html>
5876 EOF
59-
77+
6078 - name : Upload artifact
6179 uses : actions/upload-pages-artifact@v3
6280 with :
63- path : docs
64-
65- deploy :
66- name : Deploy to GitHub Pages
67- needs : build-docs
68- runs-on : ubuntu-latest
69- environment :
70- name : github-pages
71- url : ${{ steps.deploy.outputs.page_url }}
72- steps :
73- - name : Deploy GitHub Pages site
74- id : deploy
75- uses : actions/deploy-pages@v4
81+ path : ./docs
82+
83+ - name : Deploy to GitHub Pages
84+ id : deployment
85+ uses : actions/deploy-pages@v4
0 commit comments