spring-petclinic/.github/workflows/main.yml
nirpel-sys 94280bd6dd
Update main.yml
Signed-off-by: nirpel-sys <nirpel@jfrog.com>
2026-01-20 12:13:37 +02:00

60 lines
1.7 KiB
YAML

name: PetClinic to Artifactory
on:
push:
branches: [ "main" ]
workflow_dispatch:
jobs:
build-and-publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: 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'
# Setup JFrog CLI using OIDC
- 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-provider
oidc-audience: jfrog-github
# 1 & 2: Compile and Run Tests
- name: Compile and Test
run: ./mvnw clean test
# 3: Package as Docker image
- name: Build Docker Image
run: |
./mvnw spring-boot:build-image \
-Dspring-boot.build-image.imageName=petclinic-app:${{ github.run_number }}
# 4: Publish to Artifactory
- name: Publish to Artifactory
run: |
# Extract hostname (e.g., myinstance.jfrog.io)
JF_HOST=$(echo ${{ secrets.JF_URL }} | sed 's|https://||')
DOCKER_REPO="docker-local"
# Tag and Push
REMOTE_TAG=$JF_HOST/$DOCKER_REPO/petclinic-app:${{ github.run_number }}
docker tag petclinic-app:${{ github.run_number }} $REMOTE_TAG
jf docker push $REMOTE_TAG --build-name=petclinic --build-number=${{ github.run_number }}
# Publish Build Info
jf rt bp petclinic ${{ github.run_number }}