mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2026-02-05 05:41:11 +00:00
57 lines
1.6 KiB
YAML
57 lines
1.6 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'
|
|
|
|
- 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
|
|
|
|
- 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: |
|
|
# Clean URL to get Hostname (e.g., myinstance.jfrog.io)
|
|
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"
|
|
|
|
# Tag, Push, and Publish Build Info
|
|
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 }}
|