Skip to content

Commit

Permalink
chore: Validate flyway on push to main (#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanNemeth authored Jan 31, 2025
1 parent 4ff2a34 commit 98f4634
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/flyway-validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Flyway Validation
on:
pull_request:
branches: [main]
workflow_call: {}

env:
FLYWAY_URL: jdbc:postgresql://localhost:5432/helios
Expand Down Expand Up @@ -36,12 +37,14 @@ jobs:
fetch-depth: 0

- name: Fetch all branches
if: github.event_name == 'pull_request'
run: |
git fetch origin ${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}
git fetch origin ${{ github.head_ref }}:refs/remotes/origin/${{ github.head_ref }}
- name: Check for changes
id: check_changes
if: github.event_name == 'pull_request'
run: |
CHANGED_PATHS=$(git diff --name-status origin/${{ github.base_ref }} origin/${{ github.head_ref }} | grep -E "server/application-server/src/main/resources/db/migration/" || true)
Expand All @@ -62,18 +65,18 @@ jobs:
fi
- name: Set up Java
if: steps.check_changes.outputs.CHANGE_DETECTED == 'true'
if: steps.check_changes.outputs.CHANGE_DETECTED == 'true' || github.event_name == 'push'
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "21"

- name: Run Gradle to apply Flyway migrations
if: steps.check_changes.outputs.CHANGE_DETECTED == 'true'
if: steps.check_changes.outputs.CHANGE_DETECTED == 'true' || github.event_name == 'push'
working-directory: ./server/application-server
run: ./gradlew flywayMigrate

- name: Run Gradle to validate Flyway migrations
if: steps.check_changes.outputs.CHANGE_DETECTED == 'true'
if: steps.check_changes.outputs.CHANGE_DETECTED == 'true' || github.event_name == 'push'
working-directory: ./server/application-server
run: ./gradlew flywayValidate
4 changes: 3 additions & 1 deletion .github/workflows/prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
branches: [main]

jobs:
validate-flyway:
uses: ./.github/workflows/flyway-validate.yml
build-prod-container:
uses: ./.github/workflows/build_docker.yml
secrets: inherit
Expand All @@ -16,4 +18,4 @@ jobs:
environment: production
client_image_tag: "latest"
application_server_image_tag: "latest"
webhook_listener_image_tag: "latest"
webhook_listener_image_tag: "latest"

0 comments on commit 98f4634

Please sign in to comment.