Skip to content

Helm

Helm #70

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
jobs:
build_gateway_service:
name: Build Gateway Service
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && github.event.head_commit.added == 'gateway-service/*' || github.event.head_commit.modified == 'gateway-service/*' || github.event.head_commit.removed == 'gateway-service/*' }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'
- name: Build Maven Project
run: mvn -B package --file gateway-service/pom.xml
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build Docker Image
run: |
cd gateway-service
docker build -t ${{ secrets.DOCKER_USERNAME }}/gateway-service:${{ github.run_number }} .
- name: Save Docker Image to Tarball
run: docker save ${{ secrets.DOCKER_USERNAME }}/gateway-service:${{ github.run_number }} -o gateway-service.tar
- name: Upload Docker Image Tarball
uses: actions/upload-artifact@v4
with:
name: gateway-service-image
path: gateway-service.tar
compression-level: 0
retention-days: 1
build_discovery_service:
name: Build Discovery Service
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && github.event.head_commit.added == 'discovery-service/*' || github.event.head_commit.modified == 'discovery-service/*' || github.event.head_commit.removed == 'discovery-service/*' }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'
- name: Build Maven Project
run: mvn -B package --file discovery-service/pom.xml
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build Docker Image
run: |
cd discovery-service
docker build -t ${{ secrets.DOCKER_USERNAME }}/discovery-service:${{ github.run_number }} .
- name: Save Docker Image to Tarball
run: docker save ${{ secrets.DOCKER_USERNAME }}/discovery-service:${{ github.run_number }} -o discovery-service.tar
- name: Upload Docker Image Tarball
uses: actions/upload-artifact@v3
with:
name: discovery-service-image
path: discovery-service.tar
build_auth_service:
name: Build Auth Service
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && github.event.head_commit.added == 'auth-service/*' || github.event.head_commit.modified == 'auth-service/*' || github.event.head_commit.removed == 'auth-service/*' }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'
- name: Build Maven Project
run: mvn -B package --file auth-service/pom.xml
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build Docker Image
run: |
cd discovery-service
docker build -t ${{ secrets.DOCKER_USERNAME }}/auth-service:${{ github.run_number }} .
- name: Save Docker Image to Tarball
run: docker save ${{ secrets.DOCKER_USERNAME }}/auth-service:${{ github.run_number }} -o discovery-service.tar
- name: Upload Docker Image Tarball
uses: actions/upload-artifact@v3
with:
name: auth-service-image
path: auth-service.tar
build_chat_service:
name: Build Chat Service
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && github.event.head_commit.added == 'chat-service/*' || github.event.head_commit.modified == 'chat-service/*' || github.event.head_commit.removed == 'chat-service/*' }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'
- name: Build Maven Project
run: mvn -B package --file chat-service/pom.xml
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build Docker Image
run: |
cd discovery-service
docker build -t ${{ secrets.DOCKER_USERNAME }}/chat-service:${{ github.run_number }} .
- name: Save Docker Image to Tarball
run: docker save ${{ secrets.DOCKER_USERNAME }}/chat-service:${{ github.run_number }} -o discovery-service.tar
- name: Upload Docker Image Tarball
uses: actions/upload-artifact@v3
with:
name: chat-service-image
path: chat-service.tar
build_notification_service:
name: Build Notification Service
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && github.event.head_commit.added == 'notification-service/*' || github.event.head_commit.modified == 'notification-service/*' || github.event.head_commit.removed == 'notification-service/*' }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'
- name: Build Maven Project
run: mvn -B package --file notification-service/pom.xml
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build Docker Image
run: |
cd discovery-service
docker build -t ${{ secrets.DOCKER_USERNAME }}/notification-service:${{ github.run_number }} .
- name: Save Docker Image to Tarball
run: docker save ${{ secrets.DOCKER_USERNAME }}/notification-service:${{ github.run_number }} -o discovery-service.tar
- name: Upload Docker Image Tarball
uses: actions/upload-artifact@v3
with:
name: notification-service-image
path: notification-service.tar
gateway_service_tests:
name: Run Gateway Tests
runs-on: ubuntu-latest
needs: [build_gateway_service]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'
- name: Test Gateway Service
run: mvn test --file gateway-service/pom.xml
discovery_service_tests:
name: Run Discovery Service Tests
runs-on: ubuntu-latest
needs: [ build_discovery_service ]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'
- name: Test Discovery Service
run: mvn test --file discovery-service/pom.xml
auth_service_tests:
name: Run Auth Service Tests
runs-on: ubuntu-latest
needs: [ build_auth_service ]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'
- name: Test Auth Service
run: mvn test --file auth-service/pom.xml
chat_service_tests:
name: Run Chat Service Tests
runs-on: ubuntu-latest
needs: [ build_chat_service ]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'
- name: Test Chat Service
run: mvn test --file chat-service/pom.xml
notification_service_tests:
name: Run Notification Service Tests
runs-on: ubuntu-latest
needs: [ build_notification_service ]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'
- name: Test Notification Service
run: mvn test --file notification-service/pom.xml
# report_gateway_service_status:
# name: Report Gateway Service Build Status
# runs-on: ubuntu-latest
# needs: [build_gateway_service]
# steps:
# - name: Report Status
# run: |
# echo "Build Gateway Service status: ${{ needs.build_gateway_service.result }}"
#
# report_discovery_service_status:
# name: Report Discovery Service Build Status
# runs-on: ubuntu-latest
# needs: [build_discovery_service]
# steps:
# - name: Report Status
# run: |
# echo "Build Discovery Service status: ${{ needs.build_discovery_service.result }}"
#
# report_auth_service_status:
# name: Report Auth Service Build Status
# runs-on: ubuntu-latest
# needs: [build_auth_service]
# steps:
# - name: Report Status
# run: |
# echo "Build Auth Service status: ${{ needs.build_auth_service.result }}"
#
# report_chat_service_status:
# name: Report Chat Service Build Status
# runs-on: ubuntu-latest
# needs: [build_chat_service]
# steps:
# - name: Report Status
# run: |
# echo "Build Chat Service status: ${{ needs.build_chat_service.result }}"
#
#
# report_notification_service_status:
# name: Report Notification Service Build Status
# runs-on: ubuntu-latest
# needs: [build_notification_service]
# steps:
# - name: Report Status
# run: |
# echo "Build Notification Service status: ${{ needs.build_notification_service.result }}"
#
analyze_sonar:
name: SonarCloud Analysis
needs: [gateway_service_tests, discovery_service_tests, auth_service_tests, chat_service_tests, notification_service_tests]
#if: |
# always() &&
#!contains(needs.*.result, 'failure') &&
#!contains(needs.*.result, 'cancelled')
uses: ./.github/workflows/sonar.yml
secrets:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
deploy_gateway_service:
name: Deploy Gateway Service to Docker Hub
runs-on: ubuntu-latest
needs: [ analyze_sonar ]
if: |
always() &&
needs.build_gateway_service.result != 'failure' &&
needs.build_gateway_service.result != 'cancelled' &&
needs.build_gateway_service.result != 'skipped'
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download Docker Image Tarball
uses: actions/download-artifact@v4
with:
name: gateway-service-image
path: gateway-service.tar
- name: Load Docker Image from Tarball
run: docker load -i gateway-service.tar/gateway-service.tar
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Push Docker Image
run: docker push ${{ secrets.DOCKER_USERNAME }}/gateway-service:${{ github.run_number }}
deploy_discovery_service:
name: Deploy Discovery Service to Docker Hub
runs-on: ubuntu-latest
needs: [ analyze_sonar ]
if: |
always() &&
needs.build_discovery_service.result != 'failure' &&
needs.build_discovery_service.result != 'cancelled' &&
needs.build_discovery_service.result != 'skipped'
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download Docker Image Tarball
uses: actions/download-artifact@v4
with:
name: discovery-service-image
path: discovery-service.tar
- name: Load Docker Image from Tarball
run: docker load -i discovery-service.tar/discovery-service.tar
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Push Docker Image
run: docker push ${{ secrets.DOCKER_USERNAME }}/discovery-service:${{ github.run_number }}
deploy_auth_service:
name: Deploy Auth Service to Docker Hub
runs-on: ubuntu-latest
needs: [ analyze_sonar ]
if: |
always() &&
needs.build_auth_service.result != 'failure' &&
needs.build_auth_service.result != 'cancelled' &&
needs.build_auth_service.result != 'skipped'
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download Docker Image Tarball
uses: actions/download-artifact@v4
with:
name: auth-service-image
path: auth-service.tar
- name: Load Docker Image from Tarball
run: docker load -i auth-service.tar/auth-service.tar
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Push Docker Image
run: docker push ${{ secrets.DOCKER_USERNAME }}/auth-service:${{ github.run_number }}
deploy_chat_service:
name: Deploy Chat Service to Docker Hub
runs-on: ubuntu-latest
needs: [ analyze_sonar ]
if: |
always() &&
needs.build_chat_service.result != 'failure' &&
needs.build_chat_service.result != 'cancelled' &&
needs.build_chat_service.result != 'skipped'
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download Docker Image Tarball
uses: actions/download-artifact@v4
with:
name: chat-service-image
path: chat-service.tar
- name: Load Docker Image from Tarball
run: docker load -i chat-service.tar/chat-service.tar
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Push Docker Image
run: docker push ${{ secrets.DOCKER_USERNAME }}/chat-service:${{ github.run_number }}
deploy_notification_service:
name: Deploy Notification Service to Docker Hub
runs-on: ubuntu-latest
needs: [ analyze_sonar ]
if: |
always() &&
needs.build_notification_service.result != 'failure' &&
needs.build_notification_service.result != 'cancelled' &&
needs.build_notification_service.result != 'skipped'
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download Docker Image Tarball
uses: actions/download-artifact@v4
with:
name: notification-service-image
path: notification-service.tar
- name: Load Docker Image from Tarball
run: docker load -i notification-service.tar/notification-service.tar
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Push Docker Image
run: docker push ${{ secrets.DOCKER_USERNAME }}/notification-service:${{ github.run_number }}
# deploy_gateway_service_k8s:
# name: Deploy Gateway Service to Kubernetes
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v2
#
# - name: Set up Kubeconfig
# id: kubeconfig
# run: |
# mkdir -p $HOME/.kube
# echo "${{ secrets.KUBE_CONTEXT }}" > $HOME/.kube/config
#
# - name: Deploy Nginx
# run: |
# cat <<EOF | kubectl apply -f -
# apiVersion: v1
# kind: Pod
# metadata:
# name: nginx
# spec:
# containers:
# - name: nginx
# image: nginx:latest
# ports:
# - containerPort: 80
# EOF
#
# - name: Verify Deployment
# run: kubectl get pods