Skip to content

Checks that OpenAPI specs are up to date #256

Checks that OpenAPI specs are up to date

Checks that OpenAPI specs are up to date #256

Workflow file for this run

name: Checks that OpenAPI specs are up to date
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * 1"
jobs:
check-openapi-spec-up-to-date:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: make download
- uses: tj-actions/verify-changed-files@v20
id: verify-changed-openapi-specs
with:
files: incident_io_openapi.json
- uses: actions/setup-python@v5
if: steps.verify-changed-openapi-specs.outputs.files_changed == 'true'
with:
python-version: "3.10"
- name: Cache Pip
if: steps.verify-changed-openapi-specs.outputs.files_changed == 'true'
uses: actions/cache@v4
with:
path: |
~/.cache/pip
key: ${{ runner.os }}-3.10-${{ hashFiles('**/poetry.lock') }}
- name: Install Poetry
if: steps.verify-changed-openapi-specs.outputs.files_changed == 'true'
run: |
pip install poetry
- name: Install dependencies
if: steps.verify-changed-openapi-specs.outputs.files_changed == 'true'
run: |
poetry install
- name: Generate client
if: steps.verify-changed-openapi-specs.outputs.files_changed == 'true'
run: |
make generate
- name: Create new branch
if: steps.verify-changed-openapi-specs.outputs.files_changed == 'true'
run: |
branch_name=update_api_$(date "+%Y_%m_%d")
commit_message="feat: Updated API at $(date "+%Y-%m-%d")"
git config user.email "[email protected]"
git config user.name "Github Actions"
git checkout -b $branch_name
git add \
docs \
incident_io_client \
incident_io_openapi.json
git commit -m "$commit_message"
git push -u origin $branch_name
- name: Create new Pull Request
if: steps.verify-changed-openapi-specs.outputs.files_changed == 'true'
run: |
gh pr create --body "" --title "Updated API at $(date "+%Y-%m-%d")"
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}