-
Notifications
You must be signed in to change notification settings - Fork 2
39 lines (32 loc) · 1.14 KB
/
flyway-check.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: Flyway Migration Check
on:
pull_request:
branches: [ main ]
paths:
- 'backend/src/main/resources/db/migration/**'
jobs:
check-migrations:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for modified migrations
run: |
git fetch origin main:main
modified_files=$(git diff --name-only main...HEAD -- src/main/resources/db/migration/)
new_files=$(git diff --name-only --diff-filter=A main...HEAD -- src/main/resources/db/migration/)
if [ -n "$modified_files" ]; then
echo "The following existing migration files have been modified:"
echo "$modified_files"
echo "Error: Modifying existing migrations is not allowed."
exit 1
fi
if [ -n "$new_files" ]; then
echo "The following new migration files have been added:"
echo "$new_files"
echo "New migrations are allowed."
fi
if [ -z "$modified_files" ] && [ -z "$new_files" ]; then
echo "No changes to migration files detected."
fi