Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix up GitHub pages workflow. #215

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Loading