Skip to content

docapi

docapi #78

Workflow file for this run

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/main" ]; then
echo "PATH=dev.yaml" >> $GITHUB_OUTPUT
elif [[ "$REF" =~ ^refs/tags/v*beta ]]; then
echo "PATH=beta.yaml" >> $GITHUB_OUTPUT
elif [[ "$REF" =~ ^refs/tags/v* ]]; 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.vertex.yaml openapi/openapi.vertex.${{ steps.setup-variables.outputs.PATH }}
cp docapi/openapi.kernel.yaml openapi/openapi.kernel.${{ 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 openapi.*.${{ steps.setup-variables.outputs.PATH }}"
git push
fi
cd ..
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
- name: Create tag if needed
if: startsWith(github.event.client_payload.ref, 'refs/tags/v')
run: |
cd openapi
REF=${{ github.event.client_payload.ref }}
TAG="${REF#refs/tags/}"
git tag $TAG
git push origin $TAG
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}