Skip to content

Commit

Permalink
Customize GitHub pages workflow. (#215)
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock authored Apr 2, 2024
1 parent 83fdfbb commit 1879553
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 30 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# deploys to https://opensearch-project.github.io/opensearch-api-specification/
name: Deploy

on:
push:
branches:
- main

concurrency:
group: "pages"
cancel-in-progress: false

permissions:
contents: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '20'

- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
bundler-cache: true

- name: Build with Jekyll
run: |-
gem install jekyll
jekyll build
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: _site
branch: gh-pages

5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ node_modules
.idea/

# VSCode files
.vscode/
.vscode/

# Jekyll Website
_site/
2 changes: 1 addition & 1 deletion PUBLISHING_SPECS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
## Publishing OpenSearch API Specs

* 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`.
* The updated OpenAPI specs are hosted on GitHub pages at https://opensearch-project.github.io/opensearch-api-specification/.
* The [deploy](.github/workflows/deploy.yml) workflow publishes specs to [GitHub pages](https://opensearch-project.github.io/opensearch-api-specification/).
9 changes: 9 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
source: .
destination: ./_site
include:
- index.html
- favicon.ico
exclude:
- '*'
keep_files:
- opensearch-openapi.yaml
16 changes: 16 additions & 0 deletions _plugins/openapi.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module OpenAPI
def self.generate(_site, _payload)
return if @generated

Dir.chdir('tools') do
system 'npm install'
system 'npm run merge -- ../spec/opensearch-openapi.yaml ../_site/opensearch-openapi.yaml'
end

@generated = true
end
end

Jekyll::Hooks.register :site, :post_write do |site, payload|
OpenAPI.generate(site, payload)
end
Binary file added favicon.ico
Binary file not shown.
57 changes: 29 additions & 28 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
<html>
<head>
<!-- Load the latest Swagger UI code and style from npm using unpkg.com -->
<script src="https://unpkg.com/swagger-ui-dist@4/swagger-ui-bundle.js"></script>
<link rel="stylesheet" type="text/css" href="https://unpkg.com/swagger-ui-dist@4/swagger-ui.css"/>
<title>OpenSearch API Spec</title>
</head>
<body>
<div id="swagger-ui"></div> <!-- Div to hold the UI component -->
<script>
window.onload = function () {
// Begin Swagger UI call region
const ui = SwaggerUIBundle({
url: "https://github.com/opensearch-project/opensearch-api-specification/releases/download/main/opensearch-openapi.yaml",
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIBundle.SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
})
window.ui = ui
}
</script>
</body>
</html>

<head>
<script src="https://unpkg.com/swagger-ui-dist@5/swagger-ui-bundle.js"></script>
<link rel="stylesheet" type="text/css" href="https://unpkg.com/swagger-ui-dist@5/swagger-ui.css" />
<title>OpenSearch API Spec</title>
</head>

<body>
<div id="swagger-ui"></div>
<script>
window.onload = function () {
const ui = SwaggerUIBundle({
url: "opensearch-openapi.yaml",
dom_id: "#swagger-ui",
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIBundle.SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
})
window.ui = ui
}
</script>
</body>

</html>

0 comments on commit 1879553

Please sign in to comment.