chore: trigger CI to test Harbor push pwd change to admin #21
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] | |
| tags: ['v*'] | |
| workflow_dispatch: | |
| env: | |
| # Registries | |
| GHCR_REGISTRY: ghcr.io | |
| HARBOR_REGISTRY: ps-registry.pack-test.net | |
| # Image names | |
| HARBOR_IMAGE: suite-epargne/se-api | |
| GHCR_IMAGE: pack-solutions/se-api | |
| 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 or tags) | |
| # ============================================================================== | |
| build: | |
| name: Build & Push Image | |
| runs-on: ubuntu-latest | |
| needs: [test] | |
| if: github.event_name == 'push' | |
| permissions: | |
| contents: read | |
| packages: write | |
| outputs: | |
| harbor_tag: ${{ steps.meta.outputs.harbor_primary_tag }} | |
| ghcr_tag: ${{ steps.meta.outputs.ghcr_tag }} | |
| build_type: ${{ steps.meta.outputs.build_type }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Generate image metadata | |
| id: meta | |
| run: | | |
| SHA_SHORT="${GITHUB_SHA::7}" | |
| TIMESTAMP=$(date -u +%Y%m%d) | |
| # Extract version from gradle.properties for GHCR | |
| GHCR_VERSION=$(grep '^version=' gradle.properties | cut -d'=' -f2) | |
| if [[ "$GITHUB_REF" == refs/tags/v* ]]; then | |
| # Release tag - use semver for Harbor | |
| SEMVER="${GITHUB_REF#refs/tags/v}" | |
| HARBOR_PRIMARY_TAG="${SEMVER}" | |
| HARBOR_TAGS="${SEMVER},${SHA_SHORT}" | |
| BUILD_TYPE="release" | |
| else | |
| # Push to main - use timestamp-sha for Harbor | |
| HARBOR_PRIMARY_TAG="${TIMESTAMP}-${SHA_SHORT}" | |
| HARBOR_TAGS="${TIMESTAMP}-${SHA_SHORT},${SHA_SHORT}" | |
| BUILD_TYPE="dev" | |
| fi | |
| echo "harbor_primary_tag=${HARBOR_PRIMARY_TAG}" >> $GITHUB_OUTPUT | |
| echo "harbor_tags=${HARBOR_TAGS}" >> $GITHUB_OUTPUT | |
| echo "ghcr_tag=${GHCR_VERSION}" >> $GITHUB_OUTPUT | |
| echo "sha_short=${SHA_SHORT}" >> $GITHUB_OUTPUT | |
| echo "build_type=${BUILD_TYPE}" >> $GITHUB_OUTPUT | |
| echo "## Image Tags" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Build Type:** ${BUILD_TYPE}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Harbor Primary:** ${HARBOR_PRIMARY_TAG}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **GHCR:** ${GHCR_VERSION}" >> $GITHUB_STEP_SUMMARY | |
| - 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 Harbor | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.HARBOR_REGISTRY }} | |
| username: ${{ secrets.HARBOR_USERNAME }} | |
| password: ${{ secrets.HARBOR_PASSWORD }} | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| continue-on-error: true | |
| id: ghcr_login | |
| with: | |
| registry: ${{ env.GHCR_REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GHCR_PAT }} | |
| - name: Build and push to Harbor | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| platforms: linux/amd64 | |
| push: true | |
| tags: | | |
| ${{ env.HARBOR_REGISTRY }}/${{ env.HARBOR_IMAGE }}:${{ steps.meta.outputs.harbor_primary_tag }} | |
| ${{ env.HARBOR_REGISTRY }}/${{ env.HARBOR_IMAGE }}:${{ steps.meta.outputs.sha_short }} | |
| build-args: | | |
| APP_VERSION=${{ steps.meta.outputs.harbor_primary_tag }} | |
| BUILD_DATE=${{ github.event.head_commit.timestamp }} | |
| VCS_REF=${{ github.sha }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Build and push to GHCR (backup) | |
| if: steps.ghcr_login.outcome == 'success' | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| platforms: linux/amd64 | |
| push: true | |
| tags: | | |
| ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE }}:${{ steps.meta.outputs.ghcr_tag }} | |
| build-args: | | |
| APP_VERSION=${{ steps.meta.outputs.ghcr_tag }} | |
| 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 "### Harbor (Primary)" >> $GITHUB_STEP_SUMMARY | |
| echo "- \`${{ env.HARBOR_REGISTRY }}/${{ env.HARBOR_IMAGE }}:${{ steps.meta.outputs.harbor_primary_tag }}\`" >> $GITHUB_STEP_SUMMARY | |
| echo "- \`${{ env.HARBOR_REGISTRY }}/${{ env.HARBOR_IMAGE }}:${{ steps.meta.outputs.sha_short }}\`" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### GHCR (Backup)" >> $GITHUB_STEP_SUMMARY | |
| echo "- \`${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE }}:${{ steps.meta.outputs.ghcr_tag }}\`" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Commit:** \`${{ github.sha }}\`" >> $GITHUB_STEP_SUMMARY |