Skip to content

Commit

Permalink
Create a workflow to automatically push new documentation
Browse files Browse the repository at this point in the history
Signed-off-by: Quentin Guidée <[email protected]>
  • Loading branch information
quentinguidee committed Oct 30, 2023
0 parents commit 11a7e7e
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 0 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/generate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Run docapi

on:
repository_dispatch:
types: [docapi]

permissions:
contents: write

jobs:
generate:
runs-on: ubuntu-latest
concurrency:
# Ensure that only one job runs at a time, to avoid push conflicts
group: docapi
steps:
- name: Setup variables
id: setup-variables
run: |
REF=${{ github.event.client_payload.ref }}
if [ "$REF" = "refs/heads/dev" ]; then
echo "PATH=dev.yaml" >> $GITHUB_OUTPUT
elif [[ "$REF" =~ ^v[0-9].*beta ]]; then
echo "PATH=beta.yaml" >> $GITHUB_OUTPUT
elif [[ "$REF" =~ ^v[0-9] ]]; then
echo "PATH=stable.yaml" >> $GITHUB_OUTPUT
else
echo "Invalid ref: $REF"
exit 1
fi
- name: Download Vertex
uses: actions/checkout@v4
with:
repository: vertex-center/vertex
ref: ${{ github.event.client_payload.ref }}
path: vertex

- name: Download docapi
uses: actions/checkout@v4
with:
repository: quentinguidee/docapi
path: docapi

- name: Download Vertex-OpenAPI
uses: actions/checkout@v4
with:
repository: vertex-center/openapi
path: openapi

- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.21

- name: Generate openapi.yaml
run: |
cd docapi
go run ./cmd ../vertex
cd ..
if [ -f openapi/${{ steps.setup-variables.outputs.PATH }} ]; then
rm openapi/${{ steps.setup-variables.outputs.PATH }}
fi
cp docapi/openapi.yaml openapi/${{ steps.setup-variables.outputs.PATH }}
- name: Commit and push changes if needed
run: |
cd openapi
git config user.email "149347004+vertex-nexa[bot]@users.noreply.github.com"
git config user.name "vertex-nexa[bot]"
if [ -z "$(git status --porcelain)" ]; then
echo "No changes to commit"
else
git add .
git commit -m "Update ${{ steps.setup-variables.outputs.PATH }}"
git push
fi
cd ..
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}

- name: Create release if needed
if: startsWith(github.event.client_payload.ref, 'refs/tags/v')
run: |
cd openapi
git tag $REF
git push origin $REF
if [[ "$REF" =~ beta ]]; then
gh release create $REF --title "OpenAPI for Vertex $REF" --verify-tag --prerelease
else
gh release create $REF --title "OpenAPI for Vertex $REF" --verify-tag
fi
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# MIT License

Copyright (c) 2023 Quentin Guidée

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<p align="center">
<img height="96" src="https://github.com/vertex-center/vertex-design/raw/main/logos/transparent/vertex_logo_transparent.png" alt="Vertex logo" />
</p>
<h1 align="center">Vertex OpenAPI</h1>

<p align="center">
<img alt="GitHub license" src="https://img.shields.io/github/license/vertex-center/openapi?color=DE3C4B&labelColor=1E212B&style=for-the-badge">
<img alt="GitHub contributors" src="https://img.shields.io/github/contributors/vertex-center/openapi?color=DE3C4B&labelColor=1E212B&style=for-the-badge">
</p>

---

> **Note**
> Vertex OpenAPI is currently in development. Many routes are not yet documented.
---

## About

Vertex OpenAPI documents the Vertex API using the OpenAPI specification.

This repository is automatically updated with the latest API from [Vertex](https://github.com/vertex-center/vertex).
If you want to make changes, please edit the specifications directly in the Vertex source code.

## License

This project is licensed under the [MIT License](./LICENSE.md).

0 comments on commit 11a7e7e

Please sign in to comment.