updating submodule #56
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI/CI Pipeline | |
on: | |
# Triggers the workflow on push or pull request events but only for the "main" branch | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# This workflow contains a single job called "build_and_push_backend_image" | |
build_and_push_backend_image: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
recursive: true | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push tq-backend image | |
run: | | |
docker build -t ${{ secrets.DOCKER_USERNAME }}/tq-backend:latest-$GITHUB_SHA -f tq_backend/Dockerfile ./tq_backend | |
docker push ${{ secrets.DOCKER_USERNAME }}/tq-backend:latest-$GITHUB_SHA | |
docker tag ${{ secrets.DOCKER_USERNAME }}/tq-backend:latest-$GITHUB_SHA ${{ secrets.DOCKER_USERNAME }}/tq-backend:latest | |
docker push ${{ secrets.DOCKER_USERNAME }}/tq-backend:latest | |
# This workflow contains a single job called "build_and_push_frontend_web_image" | |
build_and_push_frontend_web_image: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
recursive: true | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push tq-frontend-web-light image | |
run: | | |
docker build -t ${{ secrets.DOCKER_USERNAME }}/tq-frontend-web-light:latest-$GITHUB_SHA -f tq_frontend/qtwebDockerfile ./tq_frontend | |
docker push ${{ secrets.DOCKER_USERNAME }}/tq-frontend-web-light:latest-$GITHUB_SHA | |
docker tag ${{ secrets.DOCKER_USERNAME }}/tq-frontend-web-light:latest-$GITHUB_SHA ${{ secrets.DOCKER_USERNAME }}/tq-frontend-web-light:latest | |
docker push ${{ secrets.DOCKER_USERNAME }}/tq-frontend-web-light:latest | |
# This workflow contains a single job called "build_and_push_frontend_desktop_image" | |
build_and_push_frontend_desktop_image: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
recursive: true | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push tq-frontend-desktop image | |
run: | | |
docker build -t ${{ secrets.DOCKER_USERNAME }}/tq-frontend-desktop:latest-$GITHUB_SHA -f tq_frontend/qtdeskDockerfile ./tq_frontend | |
docker push ${{ secrets.DOCKER_USERNAME }}/tq-frontend-desktop:latest-$GITHUB_SHA | |
docker tag ${{ secrets.DOCKER_USERNAME }}/tq-frontend-desktop:latest-$GITHUB_SHA ${{ secrets.DOCKER_USERNAME }}/tq-frontend-desktop:latest | |
docker push ${{ secrets.DOCKER_USERNAME }}/tq-frontend-desktop:latest | |
# This workflow contains a single job called "build_and_push_reverse_proxy_image" | |
build_and_push_reverse_proxy_image: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
recursive: true | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push tq-reverse-proxy image | |
run: | | |
docker build -t ${{ secrets.DOCKER_USERNAME }}/tq-reverse-proxy:latest-$GITHUB_SHA -f reverse-proxy/Dockerfile ./reverse-proxy | |
docker push ${{ secrets.DOCKER_USERNAME }}/tq-reverse-proxy:latest-$GITHUB_SHA | |
docker tag ${{ secrets.DOCKER_USERNAME }}/tq-reverse-proxy:latest-$GITHUB_SHA ${{ secrets.DOCKER_USERNAME }}/tq-reverse-proxy:latest | |
docker push ${{ secrets.DOCKER_USERNAME }}/tq-reverse-proxy:latest | |
deploy: | |
needs: [build_and_push_backend_image, build_and_push_frontend_web_image, build_and_push_reverse_proxy_image] | |
runs-on: ubuntu-latest | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
recursive: true | |
# Configure Workload Identity Federation and generate an access token. | |
# | |
# See https://github.com/google-github-actions/auth for more options, | |
# including authenticating via a JSON credentials file. | |
- id: 'auth' | |
name: 'Authenticate to Google Cloud' | |
uses: google-github-actions/auth@v2 | |
with: | |
credentials_json: '${{ secrets.GCP_SA_KEY }}' | |
# Get the GKE credentials so we can deploy to the cluster | |
- name: 'Set up GKE credentials' | |
uses: google-github-actions/get-gke-credentials@v2 | |
with: | |
cluster_name: '${{ secrets.GKE_CLUSTER_NAME }}' | |
location: '${{ secrets.GKE_CLUSTER_ZONE }}' | |
# verify the connection to the cluster BEFORE DEPLOYMENT | |
- name: 'Verify cluster services BEFORE DEPLOYMENT' | |
run: | | |
kubectl get services | |
kubectl get deployments | |
kubectl get pods | |
# Download and set up Kompose | |
- name: 'Download and set up Kompose' | |
run: |- | |
curl -L https://github.com/kubernetes/kompose/releases/latest/download/kompose-linux-amd64 -o kompose | |
chmod +x kompose | |
# Convert the Docker Compose file to Kubernetes manifests and apply them | |
- name: 'Convert Docker Compose to Kubernetes and apply' | |
run: |- | |
./kompose convert -f docker-compose-web.yml | |
kubectl apply -f tq-backend-service.yaml | |
kubectl apply -f tq-frontend-web-tcp-service.yaml | |
kubectl apply -f tq-reverse-proxy-tcp-service.yaml | |
kubectl apply -f tq-backend-deployment.yaml | |
kubectl apply -f tq-frontend-web-deployment.yaml | |
kubectl apply -f tq-reverse-proxy-deployment.yaml | |
# Update the image in the Kubernetes deployment | |
- name: 'Update image in Kubernetes deployment' | |
run: |- | |
kubectl set image deployment/tq-backend tq-backend=${{ secrets.DOCKER_USERNAME }}/tq-backend:latest-$GITHUB_SHA | |
kubectl set image deployment/tq-frontend-web tq-frontend-web=${{ secrets.DOCKER_USERNAME }}/tq-frontend-web-light:latest-$GITHUB_SHA | |
kubectl set image deployment/tq-reverse-proxy tq-reverse-proxy=${{ secrets.DOCKER_USERNAME }}/tq-reverse-proxy:latest-$GITHUB_SHA | |
# Check the rollout status of the deployments | |
- name: 'Check rollout status for tq-backend' | |
run: | | |
kubectl rollout status deployment/tq-backend | |
# Check the rollout status of the deployments | |
- name: 'Check rollout status for tq-frontend-web' | |
run: | | |
kubectl rollout status deployment/tq-frontend-web | |
# Check the rollout status of the deployments | |
- name: 'Check rollout status for tq-reverse-proxy' | |
run: | | |
kubectl rollout status deployment/tq-reverse-proxy | |
# verify the connection to the cluster AFTER DEPLOYMENT | |
- name: 'Verify cluster services AFTER DEPLOYMENT' | |
run: | | |
kubectl get services | |
kubectl get deployments | |
kubectl get pods |