chore(ci): create a CI workflow that generates an OpenAPI schema when a new release is made #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Generate OpenAPI Schema | |
on: | |
push: | |
branches: | |
- master | |
paths: | |
- '**' | |
- '!webview/**' | |
- '!website/**' | |
- '!.github/workflows/deploy-website.yaml' | |
- '!.github/workflows/build-webview.yaml' | |
- '!.github/workflows/build-balena-disk-image.yaml' | |
- '!.github/workflows/python-lint.yaml' | |
- '!README.md' | |
- '!docs/**' | |
- '!bin/install.sh' | |
- '!bin/upgrade_containers.sh' | |
- '!tests/**' | |
pull_request: | |
branches: | |
- master | |
paths: | |
- '**' | |
- '!webview/**' | |
- '!website/**' | |
- '!.github/workflows/deploy-website.yaml' | |
- '!.github/workflows/build-webview.yaml' | |
- '!.github/workflows/build-balena-disk-image.yaml' | |
- '!.github/workflows/python-lint.yaml' | |
- '!README.md' | |
- '!docs/**' | |
- '!bin/install.sh' | |
- '!bin/upgrade_containers.sh' | |
- '!tests/**' | |
workflow_call: | |
jobs: | |
generate-openapi-schema: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v3 | |
with: | |
python-version: "3.11" | |
- name: Install and configure Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
version: 1.8.3 | |
virtualenvs-create: true | |
virtualenvs-in-project: false | |
virtualenvs-path: ~/.venv | |
installer-parallel: true | |
- name: Install dependencies | |
run: | | |
poetry install --only=docker-image-builder | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
id: cache | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-x86 | |
restore-keys: | | |
${{ runner.os }}-x86 | |
- name: Build Images | |
run: | | |
poetry run python tools/image_builder \ | |
--dockerfiles-only \ | |
--disable-cache-mounts | |
docker compose -f docker-compose.dev.yml build | |
- name: Start the Containers | |
run: | | |
docker compose -f docker-compose.dev.yml up -d | |
- name: Generate OpenAPI Schema | |
run: | | |
docker compose -f docker-compose.dev.yml exec anthias-server \ | |
./manage.py spectacular --file anthias-api-schema.yml | |
- name: Upload the OpenAPI Schema | |
uses: actions/upload-artifact@v3 | |
with: | |
name: anthias-api-schema | |
path: anthias-api-schema.yml |