|
13 | 13 | tags: [ '*.*.*' ] |
14 | 14 |
|
15 | 15 | jobs: |
16 | | - build: |
| 16 | + maven-build: |
17 | 17 | runs-on: ubuntu-latest |
18 | 18 |
|
19 | 19 | steps: |
20 | 20 | - uses: actions/checkout@v4 |
21 | | - - name: Set up JDK 17 |
| 21 | + - name: Set up JDK 21 |
22 | 22 | uses: actions/setup-java@v4 |
23 | 23 | with: |
24 | 24 | java-version: '21' |
25 | 25 | distribution: 'temurin' |
26 | 26 | cache: maven |
27 | | - - name: Build with Maven |
28 | | - run: mvn -B test package --file pom.xml |
29 | | - |
30 | | - # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive |
| 27 | + - name: Extract Maven project version |
| 28 | + run: | |
| 29 | + echo "version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT |
| 30 | + id: get_version |
| 31 | + - name: Build and Test |
| 32 | + id: build-and-test |
| 33 | + run: mvn -s .github/maven/settings.xml --batch-mode --update-snapshots test |
| 34 | + continue-on-error: true |
| 35 | + - name: Upload test logs if tests failed |
| 36 | + if: steps.build-and-test.outcome != 'success' |
| 37 | + uses: actions/upload-artifact@v4 |
| 38 | + with: |
| 39 | + name: surefire-reports |
| 40 | + path: target/surefire-reports/ |
| 41 | + - name: Fail build if tests failed |
| 42 | + if: steps.build-and-test.outcome != 'success' |
| 43 | + run: exit 1 |
| 44 | + - name: Integration Tests |
| 45 | + id: integration-tests |
| 46 | + run: mvn -s .github/maven/settings.xml --batch-mode --update-snapshots verify -DskipTests=true |
| 47 | + continue-on-error: true |
| 48 | + - name: Upload test logs if tests failed |
| 49 | + if: steps.integration-tests.outcome != 'success' |
| 50 | + uses: actions/upload-artifact@v4 |
| 51 | + with: |
| 52 | + name: failsafe-reports |
| 53 | + path: target/failsafe-reports/ |
| 54 | + - name: Fail build if tests failed |
| 55 | + if: steps.integration-tests.outcome != 'success' |
| 56 | + run: exit 1 |
| 57 | + - name: Package |
| 58 | + run: | |
| 59 | + mvn -s .github/maven/settings.xml --batch-mode --update-snapshots -DskipTests=true package |
| 60 | + - uses: actions/cache@v4 |
| 61 | + with: |
| 62 | + path: . |
| 63 | + key: builddir-${{ github.run_id }} |
| 64 | + # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive |
31 | 65 | - name: Update dependency graph |
32 | 66 | uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6 |
| 67 | + |
| 68 | + docker-publish: |
| 69 | + name: Docker Build and Publish |
| 70 | + if: github.ref_name == 'develop' || github.ref_name == '*.*.*' |
| 71 | + needs: maven-build |
| 72 | + runs-on: ubuntu-latest |
| 73 | + permissions: |
| 74 | + contents: read |
| 75 | + packages: write |
| 76 | + |
| 77 | + steps: |
| 78 | + - uses: actions/cache@v4 |
| 79 | + with: |
| 80 | + path: . |
| 81 | + key: builddir-${{ github.run_id }} |
| 82 | + |
| 83 | + - name: Set up Docker Buildx |
| 84 | + uses: docker/setup-buildx-action@v2 |
| 85 | + |
| 86 | + # Login against a Docker registry except on PR |
| 87 | + # https://github.com/docker/login-action |
| 88 | + - name: Log into registry ${{ env.REGISTRY }} |
| 89 | + if: github.event_name != 'pull_request' |
| 90 | + uses: docker/login-action@v2 |
| 91 | + with: |
| 92 | + registry: ${{ env.REGISTRY }} |
| 93 | + username: ${{ github.actor }} |
| 94 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 95 | + |
| 96 | + # Extract metadata (tags, labels) for Docker |
| 97 | + # https://github.com/docker/metadata-action |
| 98 | + - name: Extract Docker metadata |
| 99 | + id: meta |
| 100 | + uses: docker/metadata-action@v4 |
| 101 | + with: |
| 102 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 103 | + |
| 104 | + # Build and push Docker image with Buildx (don't push on PR) |
| 105 | + # https://github.com/docker/build-push-action |
| 106 | + - name: Build and push Docker image |
| 107 | + uses: docker/build-push-action@v6 |
| 108 | + with: |
| 109 | + context: . |
| 110 | + file: docker/Dockerfile |
| 111 | + platforms: linux/amd64,linux/arm64 |
| 112 | + build-args: TAG=${{needs.maven-build.outputs.version}} |
| 113 | + push: ${{ github.event_name != 'pull_request' }} |
| 114 | + tags: ${{ steps.meta.outputs.tags }} |
| 115 | + labels: ${{ steps.meta.outputs.labels }} |
0 commit comments