Skip to content

docapi

docapi #5

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/dev" ]; then
echo "path=dev.yaml" >> $GITHUB_ENV
elif [[ "$REF" =~ ^v[0-9].*beta ]]; then
echo "path=beta.yaml" >> $GITHUB_ENV
elif [[ "$REF" =~ ^v[0-9] ]]; then
echo "path=stable.yaml" >> $GITHUB_ENV
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 "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
if [ -z "$(git status --porcelain)" ]; then
echo "No changes to commit"
else
git add .
git commit -m "Update ${{ steps.setup-variables.outputs.path }}/openapi.yaml"
git push
fi
cd ..
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_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.GITHUB_TOKEN }}