Skip to content

Java CI/CD Pipeline #10

Java CI/CD Pipeline

Java CI/CD Pipeline #10

Workflow file for this run

name: Java CI/CD Pipeline
on:
workflow_dispatch:
# push:
# branches:
# - main
# pull_request:
# branches:
# - main
jobs:
Build:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the code from GitHub repository
- name: Checkout repository
uses: actions/[email protected]
# Step 2: Set up JDK 17 (or any version you need)
# - name: Set up JDK
# uses: actions/[email protected]
# with:
# java-version: '17'
# distribution: 'microsoft'
# setup maven
# - name: setup Maven
# with:
# maven-version: 3.9.0
# Step 3: Build the Java application with Maven (you can replace this with Gradle if needed)
# - name: Build with Maven
# run: mvn clean install -DskipTests
# Step 4: Package the application (skip tests during packaging)
# - name: Package the application (skip tests)
# run: mvn package -DskipTests
# Step 5: Build the Docker image
# - name: Build Docker image
# run: |
# docker build -t hassan1049/myapp:v1 .
# Step 6: Log in to Docker Hub (using GitHub Secrets)
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Step 7: Push the Docker image to Docker Hub
# - name: Push Docker image to Docker Hub
# run: |
# docker push hassan1049/myapp:v1
# Step 8: Set up minikube for Kubernetes deployment
- name: Set up kubectl
uses: medyagh/setup-minikube@master
- name: Test the cluster !
run: kubectl get pods -A
- name: Build image
run: |
export SHELL=/bin/bash
eval $(minikube -p minikube docker-env)
docker build -t hassan1049/myapp:v2 .
docker push hassan1049/myapp:v2
echo -n "verifying images:"
docker images
- name: Deploy to minikube
run: |
kubectl apply -f deployment.yaml
kubectl apply -f service.yaml
- name: Delay for a minutes
run: |
echo "wait 1 minute..."
sleep 60 # Sleep for 60 seconds (1 minutes)
- name: Try the cluster and Pods
run: |
kubectl get pods -A
kubectl get pods
- name: Describe pods to see if there is any issues with the pod.
run: |
kubectl describe pods
- name: get deployment details
run: |
kubectl get deployments
kubectl describe deployment myapp -n default
- name: Try the cluster !
run: |
kubectl describe service myapp-service -n default
- name: Test service URLs
run: |
minikube service list
# minikube service myapp-service --url