Skip to content

Commit

Permalink
Add workflow to track schema changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchnielsen committed Feb 27, 2025
1 parent c78063d commit 6dc57d0
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/api-tracker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Prefect API tracker

'on':
# Run weekly on Monday at 9:00 AM UTC
schedule:
- cron: '0 9 * * 1'

# Allow manual triggering
workflow_dispatch: {}

# Allow testing from PRs
# TODO: remove before merge
pull_request:
branches:
- main

permissions: {}

jobs:
detect-api-drift:
permissions:
# required to read from the repo
contents: read
# required for the paths-filter GHA, if workflow triggered by PR
pull-requests: read
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # We need history to compare with previous schemas

- name: Get previous API schema
uses: actions/download-artifact@v4
with:
path: openapi.json

- name: Compare with latest schema
run: |
/bin/bash ./scripts/compare.sh
- name: Check if diff found
id: diff
uses: andstor/file-existence-action@v3
with:
files: 'diff.md'

- name: Create GitHub issue for changes
if: steps.diff.outputs.files_exists == 'true'
run: |
gh issue create \
--title='Prefect API change detected' \
--body-file='diff.md' \
--label='maintenance'
- name: Prepare current schema for upload
run: |
# Remove the previous schema file
rm openapi.json
# Rename the current schema file
mv openapi-current.json openapi.json
- name: Upload current schema for future comparison
if: steps.diff.outputs.files_exists == 'true'
uses: actions/upload-artifact@v4
with:
path: openapi.json
overwrite: true
# The flow will run every 7 days, so no need to
# hold on to the file for much longer than that.
retention-days: 10
# We want to make sure the current schema is uploaded
# at the end to generate proper incremental diffs.
if-no-files-found: error

0 comments on commit 6dc57d0

Please sign in to comment.