-
Notifications
You must be signed in to change notification settings - Fork 7
36 lines (34 loc) · 1.13 KB
/
migrations.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
name: Alembic migrations
on:
pull_request:
paths:
- "api/database/models/**"
jobs:
check_files:
name: Check files
outputs:
run_job: ${{ steps.check_files.outputs.run_job }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Is there a new migration?
id: check_files
run: |
echo "=============== list modified files ==============="
git diff --name-only HEAD^ HEAD
echo "========== check paths of modified files =========="
git diff --name-only HEAD^ HEAD > files.txt
run_job=true
while IFS= read -r file
do
echo $file
if [[ $file == api/database/models/* && ! $(git diff --name-only HEAD^ HEAD | grep -q '^api/alembic/version/') ]]; then
echo "SQL database table models have been modified and no alembic revision was found. Please create a new revision."
run_job=false
exit 1
fi
done < files.txt
echo "::set-output name=run_job::$run_job"