-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workflow to track schema changes
- Loading branch information
1 parent
c78063d
commit 6dc57d0
Showing
1 changed file
with
74 additions
and
0 deletions.
There are no files selected for viewing
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
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 |