From 11a7e7ea6c9e6927ea6992fb0962c3e0ae6773af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Quentin=20Guid=C3=A9e?= Date: Sun, 29 Oct 2023 23:16:22 -0400 Subject: [PATCH] Create a workflow to automatically push new documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Quentin Guidée --- .github/workflows/generate.yml | 94 ++++++++++++++++++++++++++++++++++ LICENSE.md | 21 ++++++++ README.md | 27 ++++++++++ 3 files changed, 142 insertions(+) create mode 100644 .github/workflows/generate.yml create mode 100644 LICENSE.md create mode 100644 README.md diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml new file mode 100644 index 0000000..84f65e1 --- /dev/null +++ b/.github/workflows/generate.yml @@ -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 }} diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..c6efe21 --- /dev/null +++ b/LICENSE.md @@ -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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..1ff33fd --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +

+ Vertex logo +

+

Vertex OpenAPI

+ +

+GitHub license +GitHub contributors +

+ +--- + +> **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).