initial commit #1
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: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| env: | |
| # ─── Versions (single source of truth) ──────────────────────────────────── | |
| EJBCA_VERSION: "9.3.7" | |
| OPENSSL_VERSION: "3.6.0" | |
| JAVA_VERSION: "17" | |
| JAVA_DISTRIBUTION: "temurin" | |
| # ─── Docker ─────────────────────────────────────────────────────────────── | |
| REGISTRY: ghcr.io | |
| IMAGE: ghcr.io/thpham/ejbca-ce | |
| PLATFORMS: linux/amd64,linux/arm64 | |
| # ─── Build artifacts ────────────────────────────────────────────────────── | |
| ARTIFACT: kimbo11ng-1.0.0-SNAPSHOT-jar-with-dependencies.jar | |
| ARTIFACT_NAME: kimbo11ng-jar | |
| jobs: | |
| # ─── Build fat JAR ────────────────────────────────────────────────────────── | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Set up JDK | |
| uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 | |
| with: | |
| java-version: ${{ env.JAVA_VERSION }} | |
| distribution: ${{ env.JAVA_DISTRIBUTION }} | |
| cache: maven | |
| - name: Install just | |
| uses: extractions/setup-just@f8a3cce218d9f83db3a2ecd90e41ac3de6cdfd9b # v3 | |
| - name: Cache EJBCA JARs | |
| uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 | |
| with: | |
| path: deps/ejbca | |
| key: ejbca-jars-${{ env.EJBCA_VERSION }} | |
| - name: Setup (extract JARs + install deps + build) | |
| run: just setup | |
| - name: Upload JAR artifact | |
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 | |
| with: | |
| name: ${{ env.ARTIFACT_NAME }} | |
| path: target/${{ env.ARTIFACT }} | |
| retention-days: 1 | |
| # ─── Build Docker image + integration tests (main only) ───────────────────── | |
| # Builds amd64 image into local daemon, runs the full test suite against it. | |
| # Image is NOT pushed — that only happens in the push job after tests pass. | |
| test: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' | |
| permissions: | |
| contents: read | |
| packages: read | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Download JAR artifact | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: ${{ env.ARTIFACT_NAME }} | |
| path: target/ | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 | |
| - name: Build Docker image (amd64, load into daemon) | |
| uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0 | |
| with: | |
| context: . | |
| file: docker/Dockerfile | |
| load: true | |
| tags: ${{ env.IMAGE }}:latest | |
| build-args: | | |
| OPENSSL_VERSION=${{ env.OPENSSL_VERSION }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Set up JDK | |
| uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 | |
| with: | |
| java-version: ${{ env.JAVA_VERSION }} | |
| distribution: ${{ env.JAVA_DISTRIBUTION }} | |
| cache: maven | |
| - name: Cache EJBCA JARs | |
| uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 | |
| with: | |
| path: deps/ejbca | |
| key: ejbca-jars-${{ env.EJBCA_VERSION }} | |
| - name: Install just | |
| uses: extractions/setup-just@f8a3cce218d9f83db3a2ecd90e41ac3de6cdfd9b # v3 | |
| - name: Install EJBCA JARs into local Maven repo | |
| run: just install-deps | |
| - name: Run integration tests (Testcontainers + mTLS) | |
| run: mvn verify -Pit | |
| - name: Upload Failsafe reports on failure | |
| if: failure() | |
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 | |
| with: | |
| name: failsafe-reports | |
| path: target/failsafe-reports/ | |
| # ─── Push multi-arch image (only after tests pass) ────────────────────────── | |
| push: | |
| needs: test | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Download JAR artifact | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: ${{ env.ARTIFACT_NAME }} | |
| path: target/ | |
| - name: Set up QEMU (multi-arch) | |
| uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 | |
| - name: Log in to GHCR | |
| uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0 | |
| with: | |
| images: ${{ env.IMAGE }} | |
| tags: | | |
| type=raw,value=latest | |
| type=raw,value=${{ env.EJBCA_VERSION }} | |
| type=sha,prefix=sha- | |
| - name: Build and push (multi-arch) | |
| uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0 | |
| with: | |
| context: . | |
| file: docker/Dockerfile | |
| push: true | |
| platforms: ${{ env.PLATFORMS }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| build-args: | | |
| OPENSSL_VERSION=${{ env.OPENSSL_VERSION }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |