Skip to content

Commit 1879553

Browse files
authored
Customize GitHub pages workflow. (#215)
Signed-off-by: dblock <[email protected]>
1 parent 83fdfbb commit 1879553

File tree

7 files changed

+103
-30
lines changed

7 files changed

+103
-30
lines changed

.github/workflows/deploy.yml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# deploys to https://opensearch-project.github.io/opensearch-api-specification/
2+
name: Deploy
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
9+
concurrency:
10+
group: "pages"
11+
cancel-in-progress: false
12+
13+
permissions:
14+
contents: write
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout the repo
21+
uses: actions/checkout@v4
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v2
25+
with:
26+
node-version: '20'
27+
28+
- name: Setup Ruby
29+
uses: ruby/setup-ruby@v1
30+
with:
31+
ruby-version: '3.3'
32+
bundler-cache: true
33+
34+
- name: Build with Jekyll
35+
run: |-
36+
gem install jekyll
37+
jekyll build
38+
39+
- name: Deploy 🚀
40+
uses: JamesIves/github-pages-deploy-action@v4
41+
with:
42+
folder: _site
43+
branch: gh-pages
44+

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@ node_modules
88
.idea/
99

1010
# VSCode files
11-
.vscode/
11+
.vscode/
12+
13+
# Jekyll Website
14+
_site/

PUBLISHING_SPECS.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
## Publishing OpenSearch API Specs
44

55
* The [build](.github/workflows/build.yml) workflow publishes [a release draft](https://github.com/opensearch-project/opensearch-api-specification/releases) whenever a change is pushed to `main`.
6-
* The updated OpenAPI specs are hosted on GitHub pages at https://opensearch-project.github.io/opensearch-api-specification/.
6+
* The [deploy](.github/workflows/deploy.yml) workflow publishes specs to [GitHub pages](https://opensearch-project.github.io/opensearch-api-specification/).

_config.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
source: .
2+
destination: ./_site
3+
include:
4+
- index.html
5+
- favicon.ico
6+
exclude:
7+
- '*'
8+
keep_files:
9+
- opensearch-openapi.yaml

_plugins/openapi.rb

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module OpenAPI
2+
def self.generate(_site, _payload)
3+
return if @generated
4+
5+
Dir.chdir('tools') do
6+
system 'npm install'
7+
system 'npm run merge -- ../spec/opensearch-openapi.yaml ../_site/opensearch-openapi.yaml'
8+
end
9+
10+
@generated = true
11+
end
12+
end
13+
14+
Jekyll::Hooks.register :site, :post_write do |site, payload|
15+
OpenAPI.generate(site, payload)
16+
end

favicon.ico

14.7 KB
Binary file not shown.

index.html

+29-28
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
11
<html>
2-
<head>
3-
<!-- Load the latest Swagger UI code and style from npm using unpkg.com -->
4-
<script src="https://unpkg.com/swagger-ui-dist@4/swagger-ui-bundle.js"></script>
5-
<link rel="stylesheet" type="text/css" href="https://unpkg.com/swagger-ui-dist@4/swagger-ui.css"/>
6-
<title>OpenSearch API Spec</title>
7-
</head>
8-
<body>
9-
<div id="swagger-ui"></div> <!-- Div to hold the UI component -->
10-
<script>
11-
window.onload = function () {
12-
// Begin Swagger UI call region
13-
const ui = SwaggerUIBundle({
14-
url: "https://github.com/opensearch-project/opensearch-api-specification/releases/download/main/opensearch-openapi.yaml",
15-
dom_id: '#swagger-ui',
16-
deepLinking: true,
17-
presets: [
18-
SwaggerUIBundle.presets.apis,
19-
SwaggerUIBundle.SwaggerUIStandalonePreset
20-
],
21-
plugins: [
22-
SwaggerUIBundle.plugins.DownloadUrl
23-
],
24-
})
25-
window.ui = ui
26-
}
27-
</script>
28-
</body>
29-
</html>
2+
3+
<head>
4+
<script src="https://unpkg.com/swagger-ui-dist@5/swagger-ui-bundle.js"></script>
5+
<link rel="stylesheet" type="text/css" href="https://unpkg.com/swagger-ui-dist@5/swagger-ui.css" />
6+
<title>OpenSearch API Spec</title>
7+
</head>
8+
9+
<body>
10+
<div id="swagger-ui"></div>
11+
<script>
12+
window.onload = function () {
13+
const ui = SwaggerUIBundle({
14+
url: "opensearch-openapi.yaml",
15+
dom_id: "#swagger-ui",
16+
deepLinking: true,
17+
presets: [
18+
SwaggerUIBundle.presets.apis,
19+
SwaggerUIBundle.SwaggerUIStandalonePreset
20+
],
21+
plugins: [
22+
SwaggerUIBundle.plugins.DownloadUrl
23+
],
24+
})
25+
window.ui = ui
26+
}
27+
</script>
28+
</body>
29+
30+
</html>

0 commit comments

Comments
 (0)