chore(flyway): manage schema personne in Flyway #13
This file contains hidden or 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
| name: CI | |
| on: | |
| pull_request: | |
| branches: [main] | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| JAVA_VERSION: '21' | |
| jobs: | |
| # ============================================================================== | |
| # Job 1: Tests (runs on PRs and pushes) | |
| # ============================================================================== | |
| test: | |
| name: Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: ${{ env.JAVA_VERSION }} | |
| cache: 'gradle' | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v3 | |
| with: | |
| gradle-version: wrapper | |
| - name: Run Unit Tests | |
| run: ./gradlew test --no-daemon --parallel | |
| - name: Run Integration Tests | |
| run: ./gradlew integrationTest --no-daemon --parallel | |
| - name: Publish Test Results | |
| if: always() | |
| uses: EnricoMi/publish-unit-test-result-action@v2 | |
| with: | |
| files: | | |
| **/build/test-results/test/TEST-*.xml | |
| **/build/test-results/integrationTest/TEST-*.xml | |
| check_name: 'Test Results' | |
| # ============================================================================== | |
| # Job 2: Build and Push Docker Image (only on push to main) | |
| # ============================================================================== | |
| build: | |
| name: Build & Push Image | |
| runs-on: ubuntu-latest | |
| needs: [test] | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Extract version from gradle.properties | |
| id: version | |
| run: | | |
| VERSION=$(grep '^version=' gradle.properties | cut -d'=' -f2) | |
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
| echo "Version: ${VERSION}" | |
| IMAGE_NAME_LOWER=$(echo "${{ env.IMAGE_NAME }}" | tr '[:upper:]' '[:lower:]') | |
| echo "image_name_lower=${IMAGE_NAME_LOWER}" >> $GITHUB_OUTPUT | |
| - name: Setup JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: ${{ env.JAVA_VERSION }} | |
| cache: 'gradle' | |
| - name: Build application JAR | |
| run: ./gradlew assembly:buildFatJar --no-daemon --parallel -x test | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GHCR_PAT }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| platforms: linux/amd64 | |
| push: true | |
| tags: | | |
| ${{ env.REGISTRY }}/${{ steps.version.outputs.image_name_lower }}:${{ steps.version.outputs.version }} | |
| ${{ env.REGISTRY }}/${{ steps.version.outputs.image_name_lower }}:latest | |
| build-args: | | |
| APP_VERSION=${{ steps.version.outputs.version }} | |
| BUILD_DATE=${{ github.event.head_commit.timestamp }} | |
| VCS_REF=${{ github.sha }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Summary | |
| run: | | |
| echo "## Build Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Image:** \`${{ env.REGISTRY }}/${{ steps.version.outputs.image_name_lower }}:${{ steps.version.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY | |
| echo "**Commit:** \`${{ github.sha }}\`" >> $GITHUB_STEP_SUMMARY |