mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2026-01-23 20:01:12 +00:00
55 lines
1.4 KiB
YAML
55 lines
1.4 KiB
YAML
name: Build and Deploy
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
pull_request:
|
|
branches: [ main ]
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: self-hosted
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Set up JDK 17
|
|
uses: actions/setup-java@v3
|
|
with:
|
|
java-version: '17'
|
|
distribution: 'temurin'
|
|
cache: maven
|
|
|
|
- name: Build with Maven
|
|
run: ./mvnw package -B
|
|
|
|
- name: Build Docker Image
|
|
run: |
|
|
docker build -t ybandala/petclinic:${{ github.sha }} .
|
|
docker tag ybandala/petclinic:${{ github.sha }} ybandala/petclinic:latest
|
|
|
|
- name: Test
|
|
run: ./mvnw test
|
|
|
|
- name: Login to dockerhub
|
|
run: echo "${{ secrets.DOCKERHUB_PASSWORD }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin
|
|
|
|
- name: Push Image to Docker Hub
|
|
run: |
|
|
docker push ybandala/petclinic:${{ github.sha }}
|
|
docker push ybandala/petclinic:latest
|
|
|
|
- name: Install kubectl
|
|
run: |
|
|
brew install kubectl
|
|
|
|
- name: Set Minikube context
|
|
run: kubectl config use-context minikube
|
|
|
|
- name: Deploy to Minikube
|
|
run: |
|
|
sed -i 's|image: .*|image: your-dockerhub-username/petclinic:'${{ github.sha }}'|' k8s/base/deployment.yaml
|
|
|
|
# Apply the Kubernetes manifests
|
|
kubectl apply -f k8s/base/
|
|
|
|
# Wait for deployment to complete
|
|
kubectl rollout status deployment/petclinic -n petclinic-dev --timeout=180s
|