forked from ParabolInc/parabol
-
Notifications
You must be signed in to change notification settings - Fork 0
47 lines (42 loc) · 1.59 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
40
41
42
43
44
45
46
47
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
if ${{ steps.new-migrations.outputs.any_deleted }}; then
echo "${{ steps.new-migrations.outputs.deleted_files_count }} migration files where renamed or deleted. Please put their original names back or restore the following files:"
for file in ${{ steps.new-migrations.outputs.deleted_files }}; do
echo $(basename $file)
done
exit 1
fi