-
Notifications
You must be signed in to change notification settings - Fork 331
39 lines (35 loc) · 1.18 KB
/
migration-order.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
name: Migration Order
on:
pull_request:
paths:
- packages/server/postgres/migrations/*.ts
jobs:
migration-order:
runs-on: ubuntu-latest
steps:
- name: Checkout master
uses: actions/checkout@v3
with:
ref: ${{ github.base_ref }}
- 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@v41
with:
files: packages/server/postgres/migrations/*.ts
- name: Check migration conflicts
run: |
for file in ${{ steps.new-migrations.outputs.added_files }}; do
FILE_NAME=$(basename $file)
if [[ "$FILE_NAME" < "${{ env.MAX_OLD_MIGRATION }}" ]]; then
echo "$FILE_NAME predates ${{ env.MAX_OLD_MIGRATION}}. Please rename it"
exit 1
else
echo "$FILE_NAME does not conflict with existing migrations on master"
fi
done