mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-15 12:25:50 +00:00
Create main.yml
This commit is contained in:
parent
f504bd0119
commit
b8be03c559
1 changed files with 86 additions and 0 deletions
86
.github/workflows/main.yml
vendored
Normal file
86
.github/workflows/main.yml
vendored
Normal file
|
@ -0,0 +1,86 @@
|
|||
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@v3
|
||||
- name: Run Checkstyle
|
||||
run: mvn checkstyle:checkstyle
|
||||
- name: Upload Checkstyle Report
|
||||
uses: actions/upload-artifact@v3
|
||||
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@v3
|
||||
- name: Run Tests
|
||||
run: mvn test
|
||||
|
||||
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@v3
|
||||
- name: Build Package
|
||||
run: mvn clean package -DskipTests
|
||||
- name: Upload JAR Artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: jar-files
|
||||
path: target/*.jar
|
||||
|
||||
build_image:
|
||||
if: github.event_name == 'pull_request'
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
- name: Login to Registry (mr)
|
||||
run: echo ${{ secrets.REGISTRY_PASS }} | docker login mr:8084 -u ${{ secrets.REGISTRY_USER }} --password-stdin
|
||||
- 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: ubuntu-latest
|
||||
needs: build
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
- name: Login to Registry (main)
|
||||
run: echo ${{ secrets.REGISTRY_PASS }} | docker login main:8083 -u ${{ secrets.REGISTRY_USER }} --password-stdin
|
||||
- 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 }}
|
Loading…
Reference in a new issue