mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-04-24 19:32:49 +00:00
85 lines
2.6 KiB
YAML
85 lines
2.6 KiB
YAML
name: CI Pipeline
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
|
|
jobs:
|
|
checkstyle:
|
|
if: github.event_name == 'pull_request'
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: maven:3.8.5-openjdk-17
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Run Checkstyle
|
|
run: mvn checkstyle:checkstyle
|
|
- name: Upload Checkstyle Report
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: checkstyle-result
|
|
path: target/checkstyle-result.xml
|
|
|
|
test:
|
|
if: github.event_name == 'pull_request'
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: maven:3.8.5-openjdk-17
|
|
needs: checkstyle
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Run Tests
|
|
run: mvn test -Dmaven.test.failure.ignore=true
|
|
|
|
build:
|
|
if: github.event_name == 'pull_request'
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: maven:3.8.5-openjdk-17
|
|
needs: test
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Build Package
|
|
run: mvn clean package -DskipTests
|
|
- name: Upload JAR Artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: jar-files
|
|
path: target/*.jar
|
|
|
|
build_image:
|
|
if: github.event_name == 'pull_request'
|
|
runs-on: self-hosted
|
|
needs: build
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
- name: Login to Registry (mr)
|
|
run: docker login mr:8084 -u ${{ vars.REGISTRY_USER }} -p ${{ vars.REGISTRY_PASS }}
|
|
- name: Extract Short SHA
|
|
id: vars
|
|
run: echo "::set-output name=short_sha::$(echo $GITHUB_SHA | cut -c1-7)"
|
|
- name: Build Docker Image (mr)
|
|
run: docker build -t mr:8084/spring-petclinic:${{ steps.vars.outputs.short_sha }} .
|
|
- name: Push Docker Image (mr)
|
|
run: docker push mr:8084/spring-petclinic:${{ steps.vars.outputs.short_sha }}
|
|
|
|
build_image_main:
|
|
if: github.ref == 'refs/heads/main'
|
|
runs-on: self-hosted
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
- name: Login to Registry (main)
|
|
run: docker login main:8083 -u ${{ vars.REGISTRY_USER }} -p ${{ vars.REGISTRY_PASS }}
|
|
- name: Extract Short SHA
|
|
id: vars
|
|
run: echo "::set-output name=short_sha::$(echo $GITHUB_SHA | cut -c1-7)"
|
|
- name: Build Docker Image (main)
|
|
run: docker build -t main:8083/spring-petclinic:${{ steps.vars.outputs.short_sha }} .
|
|
- name: Push Docker Image (main)
|
|
run: docker push main:8083/spring-petclinic:${{ steps.vars.outputs.short_sha }}
|