diff --git a/.github/workflows/Petclinic2Artifactory b/.github/workflows/Petclinic2Artifactory new file mode 100644 index 000000000..e07ba8d19 --- /dev/null +++ b/.github/workflows/Petclinic2Artifactory @@ -0,0 +1,64 @@ +name: PetClinic to Artifactory + +on: + push: + branches: [ "main" ] + pull_request: # Added to allow Frogbot to scan incoming PRs + workflow_dispatch: + +jobs: + build-and-publish: + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + pull-requests: write # Required for Frogbot to comment on PRs + security-events: write + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: 'maven' + + - name: Set up JFrog CLI + uses: jfrog/setup-jfrog-cli@v4 + env: + JF_URL: ${{ secrets.JF_URL }} + with: + version: latest + oidc-provider-name: github-oidc + oidc-audience: jfrog-github + + # --- START FROGBOT SCAN --- + - name: Frogbot Scan + uses: jfrog/frogbot@v2 + env: + JF_URL: ${{ secrets.JF_URL }} + # Frogbot uses the OIDC configuration from the setup-jfrog-cli step + JF_GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # --- END FROGBOT SCAN --- + + - name: Build and Test + run: ./mvnw clean test + + - name: Build Docker Image + run: | + ./mvnw spring-boot:build-image \ + -Dspring-boot.build-image.imageName=petclinic-app:${{ github.run_number }} + + - name: Publish to JFrog + run: | + JF_HOST=$(echo "${{ secrets.JF_URL }}" | sed 's|https://||' | sed 's|/||g') + DOCKER_REPO="docker-local" + IMAGE_NAME="petclinic-app:${{ github.run_number }}" + REMOTE_TAG="$JF_HOST/$DOCKER_REPO/$IMAGE_NAME" + + docker tag "$IMAGE_NAME" "$REMOTE_TAG" + jf docker push "$REMOTE_TAG" --build-name=petclinic-trial --build-number=${{ github.run_number }} + jf rt bp petclinic-trial ${{ github.run_number }}