mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-15 20:25:50 +00:00
Final pipeline check
This commit is contained in:
parent
4a615e382c
commit
9218e93fde
1 changed files with 54 additions and 35 deletions
89
.github/workflows/maven-build.yml
vendored
89
.github/workflows/maven-build.yml
vendored
|
@ -2,6 +2,9 @@ name: Successfull merge pipeline
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
@ -11,13 +14,7 @@ jobs:
|
||||||
java: [ '17' ]
|
java: [ '17' ]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Install kubectl
|
|
||||||
uses: azure/setup-kubectl@v4
|
|
||||||
with:
|
|
||||||
version: 'v1.29.0'
|
|
||||||
id: install
|
|
||||||
|
|
||||||
|
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
name: Checkout code
|
name: Checkout code
|
||||||
|
|
||||||
|
@ -32,50 +29,70 @@ jobs:
|
||||||
run: chmod a+x mvnw
|
run: chmod a+x mvnw
|
||||||
|
|
||||||
- name: Maven install dependencies
|
- name: Maven install dependencies
|
||||||
run: ./mvnw clean install package
|
run: ./mvnw clean package
|
||||||
|
|
||||||
# - name: Upload JAR artifact
|
- name: Upload JAR artifact
|
||||||
# uses: actions/upload-artifact@4
|
uses: actions/upload-artifact@v4
|
||||||
# with:
|
|
||||||
# name: grid-capstone
|
|
||||||
# path: ./target/*.jar
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# - name: Login to ACR
|
|
||||||
# uses: docker/login-action@v3
|
|
||||||
# with:
|
|
||||||
|
|
||||||
# registry: ${{ vars.ACR_NAME }}.azurecr.io
|
|
||||||
# username: ${{ secrets.AZURE_CLIENT_ID }}
|
|
||||||
# password: ${{ secrets.AZURE_CLIENT_SECRET }}
|
|
||||||
|
|
||||||
|
|
||||||
- uses: azure/login@v2
|
|
||||||
name: Azure Login
|
|
||||||
with:
|
with:
|
||||||
creds: '{"clientId":"${{ secrets.AZURE_CLIENT_ID }}","clientSecret":"${{ secrets.AZURE_CLIENT_SECRET }}","subscriptionId":"${{ secrets.AZURE_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.AZURE_TENANT_ID }}"}'
|
name: app-protector
|
||||||
|
path: ./target/*.jar
|
||||||
|
|
||||||
|
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
java: [ '17' ]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
name: Checkout code
|
||||||
|
|
||||||
|
- name: Set up JDK ${{matrix.java}}
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
java-version: ${{matrix.java}}
|
||||||
|
distribution: 'temurin'
|
||||||
|
cache: maven
|
||||||
|
|
||||||
|
- name: Add executable permissions
|
||||||
|
run: chmod a+x mvnw
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: ./mvnw test
|
||||||
|
|
||||||
|
- name: Generate HTML report
|
||||||
|
run: ./mvnw surefire-report:report
|
||||||
|
|
||||||
|
|
||||||
|
- name: Upload test results
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: test-reports
|
||||||
|
path: target/site/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
docker:
|
||||||
|
needs: [build, test]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
- name: Docker Build and push
|
- name: Docker Build and push
|
||||||
run: |
|
run: |
|
||||||
az acr login --name ${{ vars.ACR_NAME }}
|
az acr login --name ${{ vars.ACR_NAME }}
|
||||||
docker build -t ${{ vars.ACR_NAME }}.azurecr.io/grid-capstone:${{ github.sha }} .
|
docker build -t ${{ vars.ACR_NAME }}.azurecr.io/grid-capstone:${{ github.sha }} .
|
||||||
docker push ${{ vars.ACR_NAME }}.azurecr.io/grid-capstone:${{ github.sha }}
|
docker push ${{ vars.ACR_NAME }}.azurecr.io/grid-capstone:${{ github.sha }}
|
||||||
|
|
||||||
- name: Getting access to the cluster
|
|
||||||
run: |
|
|
||||||
az aks get-credentials --resource-group grid-capstone --name dev-grid-cluster --admin --overwrite-existing
|
|
||||||
kubectl get pods
|
|
||||||
kubectl get nodes
|
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
needs: build
|
needs: [build, test, docker]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Automatic deployment
|
- name: Automatic deployment
|
||||||
run: |
|
run: |
|
||||||
git config --global user.name 'Kacper Piasecki'
|
git config --global user.name 'Kacper Piasecki'
|
||||||
|
@ -89,6 +106,7 @@ jobs:
|
||||||
git add .
|
git add .
|
||||||
git commit -m "Kubernetes manifests file update: $(date)"
|
git commit -m "Kubernetes manifests file update: $(date)"
|
||||||
git push
|
git push
|
||||||
|
|
||||||
- name: Install kubectl
|
- name: Install kubectl
|
||||||
uses: azure/setup-kubectl@v4
|
uses: azure/setup-kubectl@v4
|
||||||
with:
|
with:
|
||||||
|
@ -99,7 +117,8 @@ jobs:
|
||||||
name: Azure Login
|
name: Azure Login
|
||||||
with:
|
with:
|
||||||
creds: '{"clientId":"${{ secrets.AZURE_CLIENT_ID }}","clientSecret":"${{ secrets.AZURE_CLIENT_SECRET }}","subscriptionId":"${{ secrets.AZURE_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.AZURE_TENANT_ID }}"}'
|
creds: '{"clientId":"${{ secrets.AZURE_CLIENT_ID }}","clientSecret":"${{ secrets.AZURE_CLIENT_SECRET }}","subscriptionId":"${{ secrets.AZURE_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.AZURE_TENANT_ID }}"}'
|
||||||
- name: Getting access to the cluster
|
|
||||||
|
- name: Deploy new version of an image to the cluster
|
||||||
run: |
|
run: |
|
||||||
az aks get-credentials --resource-group grid-capstone --name dev-grid-cluster --admin --overwrite-existing
|
az aks get-credentials --resource-group grid-capstone --name dev-grid-cluster --admin --overwrite-existing
|
||||||
kubectl apply -f ./cicd/grid-capstone-k8s-manifests
|
kubectl apply -f ./cicd/grid-capstone-k8s-manifests
|
||||||
|
|
Loading…
Reference in a new issue