Merge pull request #1977 from booklore-app/develop
Merge develop into master for release
This commit is contained in:
@@ -16,25 +16,31 @@ concurrency:
|
|||||||
jobs:
|
jobs:
|
||||||
check-for-migrations:
|
check-for-migrations:
|
||||||
name: Check for DB Migrations
|
name: Check for DB Migrations
|
||||||
if: github.event_name == 'pull_request' && (github.base_ref == 'master' || github.base_ref == 'develop')
|
if: github.event_name == 'pull_request' && ((github.base_ref == 'master' && github.head_ref == 'develop') || github.base_ref == 'develop')
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
has_migrations: ${{ steps.filter.outputs.migrations }}
|
has_migrations: ${{ steps.check_migrations.outputs.has_migrations }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository for Diff
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Detect Migration Changes
|
|
||||||
uses: dorny/paths-filter@v3
|
|
||||||
id: filter
|
|
||||||
with:
|
with:
|
||||||
filters: |
|
fetch-depth: 0
|
||||||
migrations:
|
|
||||||
- 'booklore-api/src/main/resources/db/migration/V*.sql'
|
- name: Detect Flyway Migration Changes
|
||||||
|
id: check_migrations
|
||||||
|
run: |
|
||||||
|
# Compare PR head with the target base branch
|
||||||
|
if git diff --name-only origin/${{ github.base_ref }}...HEAD | grep -q "booklore-api/src/main/resources/db/migration/V.*.sql"; then
|
||||||
|
echo "Migration file changes detected. Proceeding with migration preview."
|
||||||
|
echo "has_migrations=true" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "No migration file changes detected. Skipping migration preview."
|
||||||
|
echo "has_migrations=false" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
flyway-migration-preview:
|
flyway-migration-preview:
|
||||||
name: Flyway DB Migration Preview
|
name: Flyway DB Migration Preview
|
||||||
needs: [check-for-migrations]
|
needs: [ check-for-migrations ]
|
||||||
if: needs.check-for-migrations.outputs.has_migrations == 'true'
|
if: needs.check-for-migrations.outputs.has_migrations == 'true'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
services:
|
services:
|
||||||
@@ -85,36 +91,46 @@ jobs:
|
|||||||
- name: Confirm Flyway Dry Run Success
|
- name: Confirm Flyway Dry Run Success
|
||||||
run: echo "✅ Flyway migration preview successful. Migrations can be applied cleanly."
|
run: echo "✅ Flyway migration preview successful. Migrations can be applied cleanly."
|
||||||
|
|
||||||
test-pr:
|
build-and-push:
|
||||||
name: Run Tests on Pull Request
|
needs: [ check-for-migrations, flyway-migration-preview ]
|
||||||
needs: [check-for-migrations, flyway-migration-preview]
|
if: always() && (needs.flyway-migration-preview.result == 'success' || needs.flyway-migration-preview.result == 'skipped')
|
||||||
if: github.event_name == 'pull_request' && (needs.flyway-migration-preview.result == 'success' || needs.flyway-migration-preview.result == 'skipped')
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: write
|
||||||
|
packages: write
|
||||||
|
issues: read
|
||||||
checks: write
|
checks: write
|
||||||
pull-requests: write
|
pull-requests: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Detect Changed Paths
|
|
||||||
uses: dorny/paths-filter@v3
|
|
||||||
id: filter
|
|
||||||
with:
|
with:
|
||||||
filters: |
|
fetch-depth: 0
|
||||||
backend:
|
|
||||||
- 'booklore-api/**'
|
- name: Authenticate to Docker Hub
|
||||||
image_build:
|
if: github.event_name == 'push'
|
||||||
- 'booklore-api/**'
|
uses: docker/login-action@v3
|
||||||
- 'booklore-ui/**'
|
with:
|
||||||
- 'Dockerfile'
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
- 'start.sh'
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Authenticate to GitHub Container Registry
|
||||||
|
if: github.event_name == 'push'
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ github.token }}
|
||||||
|
|
||||||
|
- name: Set Up QEMU for Multi-Architecture Builds
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Set Up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Set Up JDK 21
|
- name: Set Up JDK 21
|
||||||
if: steps.filter.outputs.backend == 'true'
|
|
||||||
uses: actions/setup-java@v5
|
uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
java-version: '21'
|
java-version: '21'
|
||||||
@@ -122,17 +138,16 @@ jobs:
|
|||||||
cache: 'gradle'
|
cache: 'gradle'
|
||||||
|
|
||||||
- name: Execute Backend Tests
|
- name: Execute Backend Tests
|
||||||
if: steps.filter.outputs.backend == 'true'
|
|
||||||
id: backend_tests
|
id: backend_tests
|
||||||
working-directory: ./booklore-api
|
working-directory: ./booklore-api
|
||||||
run: |
|
run: |
|
||||||
echo "Running backend tests..."
|
echo "Running backend tests with testcontainers..."
|
||||||
./gradlew test --no-daemon --parallel --build-cache
|
./gradlew test --no-daemon --parallel --build-cache
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
- name: Publish Backend Test Results
|
- name: Publish Backend Test Results
|
||||||
if: always() && steps.backend_tests.conclusion != 'skipped'
|
|
||||||
uses: EnricoMi/publish-unit-test-result-action@v2
|
uses: EnricoMi/publish-unit-test-result-action@v2
|
||||||
|
if: always()
|
||||||
with:
|
with:
|
||||||
files: booklore-api/build/test-results/**/*.xml
|
files: booklore-api/build/test-results/**/*.xml
|
||||||
check_name: Backend Test Results
|
check_name: Backend Test Results
|
||||||
@@ -141,10 +156,10 @@ jobs:
|
|||||||
report_suite_logs: 'any'
|
report_suite_logs: 'any'
|
||||||
|
|
||||||
- name: Upload Backend Test Reports
|
- name: Upload Backend Test Reports
|
||||||
if: always() && steps.backend_tests.conclusion != 'skipped'
|
|
||||||
uses: actions/upload-artifact@v6
|
uses: actions/upload-artifact@v6
|
||||||
|
if: always()
|
||||||
with:
|
with:
|
||||||
name: test-reports-pr-${{ github.event.pull_request.number }}
|
name: test-reports
|
||||||
path: |
|
path: |
|
||||||
booklore-api/build/reports/tests/
|
booklore-api/build/reports/tests/
|
||||||
booklore-api/build/test-results/
|
booklore-api/build/test-results/
|
||||||
@@ -156,89 +171,7 @@ jobs:
|
|||||||
echo "❌ Backend tests failed! Check the test results above."
|
echo "❌ Backend tests failed! Check the test results above."
|
||||||
exit 1
|
exit 1
|
||||||
|
|
||||||
- name: Skip Backend Tests
|
|
||||||
if: steps.filter.outputs.backend == 'false'
|
|
||||||
run: |
|
|
||||||
echo "✅ No backend changes detected. Skipping backend tests."
|
|
||||||
|
|
||||||
- name: PR Validation Complete
|
|
||||||
run: |
|
|
||||||
echo "✅ All PR validation checks passed!"
|
|
||||||
echo "Images will be built and pushed when this PR is merged."
|
|
||||||
|
|
||||||
build-and-push:
|
|
||||||
name: Build and Push Docker Images
|
|
||||||
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop')
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
packages: write
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout Repository
|
|
||||||
uses: actions/checkout@v6
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Detect Changed Paths
|
|
||||||
uses: dorny/paths-filter@v3
|
|
||||||
id: filter
|
|
||||||
with:
|
|
||||||
filters: |
|
|
||||||
backend:
|
|
||||||
- 'booklore-api/**'
|
|
||||||
image_build:
|
|
||||||
- 'booklore-api/**'
|
|
||||||
- 'booklore-ui/**'
|
|
||||||
- 'Dockerfile'
|
|
||||||
- 'start.sh'
|
|
||||||
|
|
||||||
- name: Skip Build and Push
|
|
||||||
if: steps.filter.outputs.image_build == 'false'
|
|
||||||
run: |
|
|
||||||
echo "✅ No backend/frontend/Docker changes detected. Skipping image build and publish."
|
|
||||||
|
|
||||||
- name: Set Up JDK 21
|
|
||||||
if: steps.filter.outputs.backend == 'true'
|
|
||||||
uses: actions/setup-java@v5
|
|
||||||
with:
|
|
||||||
java-version: '21'
|
|
||||||
distribution: 'temurin'
|
|
||||||
cache: 'gradle'
|
|
||||||
|
|
||||||
- name: Execute Backend Tests
|
|
||||||
if: steps.filter.outputs.backend == 'true'
|
|
||||||
working-directory: ./booklore-api
|
|
||||||
run: |
|
|
||||||
echo "Running backend tests before building image..."
|
|
||||||
./gradlew test --no-daemon --parallel --build-cache
|
|
||||||
|
|
||||||
- name: Authenticate to Docker Registries
|
|
||||||
if: steps.filter.outputs.image_build == 'true'
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
||||||
|
|
||||||
- name: Authenticate to GitHub Container Registry
|
|
||||||
if: steps.filter.outputs.image_build == 'true'
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: ghcr.io
|
|
||||||
username: ${{ github.actor }}
|
|
||||||
password: ${{ github.token }}
|
|
||||||
|
|
||||||
- name: Set Up QEMU for Multi-Architecture Builds
|
|
||||||
if: steps.filter.outputs.image_build == 'true'
|
|
||||||
uses: docker/setup-qemu-action@v3
|
|
||||||
|
|
||||||
- name: Set Up Docker Buildx
|
|
||||||
if: steps.filter.outputs.image_build == 'true'
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Retrieve Latest Master Version Tag
|
- name: Retrieve Latest Master Version Tag
|
||||||
if: steps.filter.outputs.image_build == 'true'
|
|
||||||
id: get_version
|
id: get_version
|
||||||
run: |
|
run: |
|
||||||
latest_tag=$(git tag --list "v*" --sort=-v:refname | head -n 1)
|
latest_tag=$(git tag --list "v*" --sort=-v:refname | head -n 1)
|
||||||
@@ -247,7 +180,7 @@ jobs:
|
|||||||
echo "Latest master tag: $latest_tag"
|
echo "Latest master tag: $latest_tag"
|
||||||
|
|
||||||
- name: Determine Version Bump (Master Only)
|
- name: Determine Version Bump (Master Only)
|
||||||
if: steps.filter.outputs.image_build == 'true' && github.ref == 'refs/heads/master'
|
if: github.ref == 'refs/heads/master'
|
||||||
id: determine_bump
|
id: determine_bump
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ github.token }}
|
GH_TOKEN: ${{ github.token }}
|
||||||
@@ -303,7 +236,6 @@ jobs:
|
|||||||
echo "new_tag=$next_version" >> $GITHUB_ENV
|
echo "new_tag=$next_version" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Generate Image Tag
|
- name: Generate Image Tag
|
||||||
if: steps.filter.outputs.image_build == 'true'
|
|
||||||
id: set_image_tag
|
id: set_image_tag
|
||||||
run: |
|
run: |
|
||||||
branch="${GITHUB_REF#refs/heads/}"
|
branch="${GITHUB_REF#refs/heads/}"
|
||||||
@@ -319,8 +251,8 @@ jobs:
|
|||||||
echo "image_tag=$image_tag" >> $GITHUB_ENV
|
echo "image_tag=$image_tag" >> $GITHUB_ENV
|
||||||
echo "Image tag: $image_tag"
|
echo "Image tag: $image_tag"
|
||||||
|
|
||||||
- name: Build and Push Docker Images
|
- name: Build and push Docker image
|
||||||
if: steps.filter.outputs.image_build == 'true'
|
if: github.event_name == 'push'
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
@@ -340,7 +272,7 @@ jobs:
|
|||||||
type=registry,ref=ghcr.io/booklore-app/booklore:buildcache,mode=max
|
type=registry,ref=ghcr.io/booklore-app/booklore:buildcache,mode=max
|
||||||
|
|
||||||
- name: Push Latest Tag (Master Only)
|
- name: Push Latest Tag (Master Only)
|
||||||
if: steps.filter.outputs.image_build == 'true' && github.ref == 'refs/heads/master'
|
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
@@ -357,7 +289,7 @@ jobs:
|
|||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
|
|
||||||
- name: Update GitHub Release Draft (Master Only)
|
- name: Update GitHub Release Draft (Master Only)
|
||||||
if: steps.filter.outputs.image_build == 'true' && github.ref == 'refs/heads/master'
|
if: github.ref == 'refs/heads/master'
|
||||||
uses: release-drafter/release-drafter@v6
|
uses: release-drafter/release-drafter@v6
|
||||||
with:
|
with:
|
||||||
tag: ${{ env.new_tag }}
|
tag: ${{ env.new_tag }}
|
||||||
@@ -366,7 +298,7 @@ jobs:
|
|||||||
GITHUB_TOKEN: ${{ github.token }}
|
GITHUB_TOKEN: ${{ github.token }}
|
||||||
|
|
||||||
- name: Publish GitHub Draft Release (Master Only)
|
- name: Publish GitHub Draft Release (Master Only)
|
||||||
if: steps.filter.outputs.image_build == 'true' && github.ref == 'refs/heads/master'
|
if: github.ref == 'refs/heads/master'
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ github.token }}
|
GITHUB_TOKEN: ${{ github.token }}
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
Reference in New Issue
Block a user