-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure flyway migrations are not changed (and validate them)
- Loading branch information
1 parent
41b1a59
commit d45be3f
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Flyway Migration Check | ||
|
||
on: | ||
pull_request: | ||
branches: [ main ] | ||
paths: | ||
- 'src/main/resources/db/migration/**' | ||
|
||
jobs: | ||
check-migrations: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '11' | ||
distribution: 'adopt' | ||
|
||
- name: Install Flyway CLI | ||
run: | | ||
wget -qO- https://repo1.maven.org/maven2/org/flywaydb/flyway-commandline/8.5.13/flyway-commandline-8.5.13-linux-x64.tar.gz | tar xvz | ||
sudo ln -s `pwd`/flyway-8.5.13/flyway /usr/local/bin | ||
- name: Check for modified migrations | ||
run: | | ||
git diff --name-only origin/main...HEAD -- backend/src/main/resources/db/migration/ > changed_files.txt | ||
if [ -s changed_files.txt ]; then | ||
echo "The following migration files have been modified:" | ||
cat changed_files.txt | ||
echo "Error: Modifying existing migrations is not allowed." | ||
exit 1 | ||
else | ||
echo "No existing migrations have been modified." | ||
fi | ||
- name: Validate new migrations | ||
run: flyway validate -locations=filesystem:backend/src/main/resources/db/migration | ||
|
||
- name: Run Flyway info | ||
run: flyway info -locations=filesystem:backend/src/main/resources/db/migration |