Skip to content

Commit 18bba38

Browse files
committed
feat: add k8s deploy pipeline for prod branch
1 parent 3548acf commit 18bba38

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

.github/workflows/k8s-deploy.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: K8s Deploy Pipeline
2+
3+
on:
4+
push:
5+
branches:
6+
- prod
7+
paths-ignore:
8+
- '**/README.md'
9+
10+
jobs:
11+
build-and-deploy:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
# Checkout code
16+
- name: Checkout code
17+
uses: actions/checkout@v3
18+
19+
# Docker Buildx setup
20+
- name: Set up Docker Buildx
21+
uses: docker/setup-buildx-action@v2
22+
23+
# Docker Hub login
24+
- name: Log in to Docker Hub
25+
uses: docker/login-action@v2
26+
with:
27+
username: ${{ secrets.DOCKER_USERNAME }}
28+
password: ${{ secrets.DOCKER_PASSWORD }}
29+
30+
# Build & Push image (SHA + latest)
31+
- name: Build and push Docker image
32+
uses: docker/build-push-action@v5
33+
with:
34+
context: .
35+
file: Dockerfile
36+
push: true
37+
platforms: linux/amd64,linux/arm64
38+
tags: |
39+
pratik50/receiptsnap-backend:${{ github.sha }}
40+
pratik50/receiptsnap-backend:latest
41+
42+
# Setup kubectl
43+
- name: Set up kubectl
44+
uses: azure/setup-kubectl@v3
45+
46+
# Configure kubeconfig
47+
- name: Configure kubeconfig
48+
run: |
49+
mkdir -p $HOME/.kube
50+
echo "${{ secrets.KUBE_CONFIG }}" | base64 -d > $HOME/.kube/config
51+
chmod 600 $HOME/.kube/config
52+
53+
# Deploy to Kubernetes cluster (Rolling Update)
54+
- name: Deploy to K8s
55+
run: |
56+
kubectl set image deployment/receiptsnap-backend \
57+
backend=pratik50/receiptsnap-backend:${{ github.sha }} \
58+
-n backend-team
59+
kubectl rollout status deployment/receiptsnap-backend \
60+
-n backend-team
61+

0 commit comments

Comments
 (0)