spring-petclinic/.github/workflows/ci-pipeline.yml
Jesse Houldsworth 8a57ffa71f adding notes
2025-03-14 16:04:59 -07:00

101 lines
4.5 KiB
YAML

name: Build with JFrog CLI (Forcing New Extractor)
on:
push:
branches: [ "main" ] # Trigger workflow on push to the main branch
pull_request:
branches: [ "main" ] # Trigger workflow on pull requests targeting main
jobs:
build:
runs-on: ubuntu-latest # Use the latest Ubuntu runner for execution
steps:
#################################################
# 1) Checkout the repository to the runner
#################################################
- name: Checkout
uses: actions/checkout@v3 # Pulls the latest code from the repository
#################################################
# 2) Set up Java environment
#################################################
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin' # Use Eclipse Temurin JDK (OpenJDK)
java-version: '17' # Ensure Java 17 is installed
#################################################
# 3) Install and Configure JFrog CLI
#################################################
- name: Setup JFrog CLI
uses: jfrog/setup-jfrog-cli@v4 # Official JFrog CLI GitHub Action
id: setup-cli
env:
JF_URL: ${{secrets.JF_RT_URL}} # Artifactory base URL (stored as a GitHub secret)
JFROG_CLI_RELEASES_REPO: '${{secrets.JF_RT_URL}}/artifactory/${{secrets.RT_REPO_MVN_VIRTUAL}}'
JFROG_CLI_EXTRACTORS_REMOTE: '${{secrets.JF_RT_URL}}/artifactory/${{secrets.RT_REPO_MVN_VIRTUAL}}'
JF_GIT_TOKEN: ${{secrets.GH_TOKEN}} # GitHub token for authentication
JF_USER: ${{secrets.ARTIFACTORY_USERNAME}} # Artifactory username
JF_PASSWORD: ${{secrets.ARTIFACTORY_IDENTITY_TOKEN}} # Artifactory identity token
#################################################
# 4) Clean the local Maven cache (optional but recommended)
#################################################
- name: Clear local Maven cache
run: rm -rf ~/.m2/repository # Ensures a clean build by removing old dependencies
- name: Ensure mvnw is executable
run: chmod +x mvnw # Make the Maven wrapper script executable
#################################################
# 5) Verify JFrog connection
#################################################
- name: ping jfrog
run: jf rt ping
#################################################
# 6) Configure Maven to use JFrog as a repository
#################################################
- name: configure maven
run: jf mvnc --global --repo-resolve-releases ${{secrets.RT_REPO_MVN_VIRTUAL}} --repo-resolve-snapshots ${{secrets.RT_REPO_MVN_VIRTUAL}}
# This sets up JFrog CLI to resolve dependencies from Artifactory
#################################################
# 7) Build project using JFrog CLI with Maven
#################################################
- name: Maven Build With JFrog CLI
run: |
jf mvn clean install \
-DskipTests=true -Denforcer.skip=true \
--build-name="spring-petclinic" \
--build-number="${{ github.run_id }}"
#################################################
# 8) Build Docker Image
#################################################
- name: Build Docker Image
run: |
docker build -t trialt0zppb.jfrog.io/onboarding-docker-local/spring-petclinic:${{ github.run_id }} .
# Builds the application into a Docker image and tags it with the GitHub run ID
#################################################
# 9) Push Docker Image to JFrog Artifactory
#################################################
- name: Docker Push to Artifactory
run: |
jfrog rt docker-push \
trialt0zppb.jfrog.io/onboarding-docker-local/spring-petclinic:${{ github.run_id }} \
onboarding-docker-local \
--build-name="spring-petclinic" \
--build-number="${{ github.run_id }}"
# Uploads the built Docker image to Artifactory for storage and deployment
#################################################
# 10) Publish Build Information to JFrog
#################################################
- name: Publish Build Info
run: |
jfrog rt build-publish "spring-petclinic" "${{ github.run_id }}"
# Publishes build metadata (dependencies, artifacts, environment) to JFrog