This repository was archived by the owner on Nov 23, 2025. It is now read-only.
Deploy Notification Service to Kubernetes #4
This file contains hidden or 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: Deploy Notification Service to Kubernetes | |
| on: | |
| workflow_run: | |
| workflows: ["Build and Package Service"] | |
| types: | |
| - completed | |
| branches: | |
| - 'main' | |
| - 'devOps' | |
| jobs: | |
| deploy: | |
| name: Deploy Notification Service to Kubernetes | |
| if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Get Commit SHA | |
| id: get_sha | |
| run: | | |
| echo "sha=$(echo ${{ github.event.workflow_run.head_sha }} | cut -c1-7)" >> $GITHUB_OUTPUT | |
| - name: Checkout K8s Config Repo | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: 'TechTorque-2025/k8s-config' | |
| token: ${{ secrets.REPO_ACCESS_TOKEN }} | |
| path: 'config-repo' | |
| ref: 'main' | |
| - name: Install kubectl | |
| uses: azure/setup-kubectl@v3 | |
| - name: Install yq | |
| run: | | |
| sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq | |
| sudo chmod +x /usr/bin/yq | |
| - name: Set Kubernetes context | |
| uses: azure/k8s-set-context@v4 | |
| with: | |
| kubeconfig: ${{ secrets.KUBE_CONFIG_DATA }} | |
| - name: Update image tag in YAML | |
| run: | | |
| yq -i '(select(.kind == "Deployment") | .spec.template.spec.containers[0].image) = "ghcr.io/techtorque-2025/notification_service:${{ steps.get_sha.outputs.sha }}"' config-repo/k8s/services/notification-deployment.yaml | |
| - name: Display file contents before apply | |
| run: | | |
| echo "--- Displaying k8s/services/notification-deployment.yaml ---" | |
| cat config-repo/k8s/services/notification-deployment.yaml | |
| echo "------------------------------------------------------------" | |
| - name: Deploy to Kubernetes | |
| run: | | |
| kubectl apply -f config-repo/k8s/services/notification-deployment.yaml | |
| kubectl rollout status deployment/notification-deployment |