From beebe79edd3da22f5a041222aa97f914b2c56fed Mon Sep 17 00:00:00 2001 From: Kyle Robbertze Date: Fri, 8 Apr 2022 15:38:58 +0200 Subject: [PATCH] ci: generate schema and push to api-client repo (#1740) * chore(api): add schema generation make target * ci: generate schema and push to api-client repo --- .github/workflows/api-schema.yml | 32 +++++++++++++++++++++++++++ api/Makefile | 4 ++++ api/libretime_api/settings/testing.py | 1 + 3 files changed, 37 insertions(+) create mode 100644 .github/workflows/api-schema.yml diff --git a/.github/workflows/api-schema.yml b/.github/workflows/api-schema.yml new file mode 100644 index 000000000..7bc9accfe --- /dev/null +++ b/.github/workflows/api-schema.yml @@ -0,0 +1,32 @@ +name: Push API schema + +on: + push: + branches: [main] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + generate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v3 + - name: Clone api-client repo + uses: actions/checkout@v3 + with: + repository: "${{ github.repository_owner }}/api-client" + path: api-client-repo + ssh-key: "${{ secrets.API_CLIENT_DEPLOY_KEY }}" + - name: Generate schema + run: | + make schema + cp schema.yml ../api-client-repo/schema.yml + working-directory: api + - name: Push schema changes to API clients + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Update schema for ${{ github.sha }} + repository: ./api-client-repo diff --git a/api/Makefile b/api/Makefile index 9f3d07a76..6a15e40a7 100644 --- a/api/Makefile +++ b/api/Makefile @@ -14,3 +14,7 @@ clean: .clean test: $(VENV) source $(VENV)/bin/activate DJANGO_SETTINGS_MODULE=libretime_api.settings.testing libretime-api test libretime_api + +schema: $(VENV) + source $(VENV)/bin/activate + DJANGO_SETTINGS_MODULE=libretime_api.settings.testing libretime-api spectacular --file schema.yml diff --git a/api/libretime_api/settings/testing.py b/api/libretime_api/settings/testing.py index 6db452181..b25b433da 100644 --- a/api/libretime_api/settings/testing.py +++ b/api/libretime_api/settings/testing.py @@ -20,6 +20,7 @@ from .prod import ( REST_FRAMEWORK, ROOT_URLCONF, SECRET_KEY, + SPECTACULAR_SETTINGS, STATIC_URL, TEMPLATES, TIME_ZONE,