chore: Handle migration conflicts #1
Workflow file for this run
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: Migration Order | |
on: | |
pull_request: | |
paths: | |
- packages/server/postgres/migrations/*.ts | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
migration-order: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout master | |
uses: actions/checkout@v3 | |
with: | |
ref: master | |
- name: Get newest migration on master | |
run: | | |
MAX_OLD_MIGRATION=$(ls packages/server/postgres/migrations | tail -n 1) | |
echo MAX_OLD_MIGRATION=$MAX_OLD_MIGRATION >> $GITHUB_ENV | |
- name: Checkout PR | |
uses: actions/checkout@v3 | |
- name: Get new migrations | |
id: new-migrations | |
uses: tj-actions/changed-files@v40 | |
with: | |
files: packages/server/postgres/migrations/*.ts | |
- name: Check migration conflicts | |
run: | | |
for file in ${{ steps.new-migrations.outputs.added_files }}; do | |
if [[ "$file" < "${{ env.MAX_OLD_MIGRATION }}" ]]; then | |
echo "Migration $file predates ${{ env.MAX_OLD_MIGRATION}}. Please rename it" | |
exit 1 | |
fi | |
done |