Skip to content

Commit 815a9e0

Browse files
Merge pull request #1 from sparrowapp-dev/akshat/workflow
added actions
2 parents 9c3b997 + a94e3e6 commit 815a9e0

3 files changed

Lines changed: 233 additions & 0 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: Deploy to AKS
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
inputs:
8+
api_version:
9+
description: 'API image version (optional, auto-generated if empty)'
10+
required: false
11+
default: ''
12+
type: string
13+
web_version:
14+
description: 'Web image version (optional, auto-generated if empty)'
15+
required: false
16+
default: ''
17+
type: string
18+
19+
env:
20+
REGISTRY: techdomeacr.azurecr.io
21+
NAMESPACE: canny
22+
23+
jobs:
24+
build-and-deploy:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
30+
- name: Login to ACR
31+
uses: Azure/docker-login@v1
32+
with:
33+
login-server: ${{ env.REGISTRY }}
34+
username: ${{ secrets.ACR_USERNAME }}
35+
password: ${{ secrets.ACR_PASSWORD }}
36+
37+
- name: Set Versions (Auto or Manual)
38+
id: versions
39+
run: |
40+
if [ -n "${{ github.event.inputs.api_version }}" ]; then
41+
# Use manual input if provided
42+
echo "api_version=${{ github.event.inputs.api_version }}" >> $GITHUB_OUTPUT
43+
echo "web_version=${{ github.event.inputs.web_version }}" >> $GITHUB_OUTPUT
44+
else
45+
# Auto-generate version: 1.0.{run_number}-{short_sha}
46+
SHORT_SHA=$(git rev-parse --short HEAD)
47+
echo "api_version=1.0.${{ github.run_number }}-$SHORT_SHA" >> $GITHUB_OUTPUT
48+
echo "web_version=1.0.${{ github.run_number }}-$SHORT_SHA" >> $GITHUB_OUTPUT
49+
fi
50+
51+
- name: Build API
52+
run: |
53+
docker build . -f apps/api/Dockerfile \
54+
-t ${{ env.REGISTRY }}/openfeedback-api:${{ steps.versions.outputs.api_version }}
55+
docker push ${{ env.REGISTRY }}/openfeedback-api:${{ steps.versions.outputs.api_version }}
56+
57+
- name: Build Web
58+
run: |
59+
docker build . -f apps/web/Dockerfile \
60+
--build-arg VITE_API_URL=https://openfeedback-api.sparrowapp.dev/api/v1 \
61+
--build-arg VITE_SUBDOMAIN=demo \
62+
--build-arg VITE_API_KEY=${{ secrets.VITE_API_KEY }} \
63+
-t ${{ env.REGISTRY }}/openfeedback-web:${{ steps.versions.outputs.web_version }}
64+
docker push ${{ env.REGISTRY }}/openfeedback-web:${{ steps.versions.outputs.web_version }}
65+
66+
- name: Replace API Version
67+
uses: richardrigutins/replace-in-files@v1
68+
with:
69+
files: "./deploymentManifests/api-deployment.yml"
70+
search-text: '_API_VERSION_'
71+
replacement-text: '${{ steps.versions.outputs.api_version }}'
72+
73+
- name: Replace Web Version
74+
uses: richardrigutins/replace-in-files@v1
75+
with:
76+
files: "./deploymentManifests/web-deployment.yml"
77+
search-text: '_WEB_VERSION_'
78+
replacement-text: '${{ steps.versions.outputs.web_version }}'
79+
80+
- name: Setup kubectl
81+
uses: azure/setup-kubectl@v3
82+
83+
- name: Set K8s Context
84+
uses: Azure/k8s-set-context@v3
85+
with:
86+
kubeconfig: ${{ secrets.KUBE_CONFIG }}
87+
88+
- name: Deploy (Deployments Only)
89+
uses: Azure/k8s-deploy@v4
90+
with:
91+
action: deploy
92+
namespace: ${{ env.NAMESPACE }}
93+
manifests: |
94+
./deploymentManifests/api-deployment.yml
95+
./deploymentManifests/web-deployment.yml
96+
images: |
97+
${{ env.REGISTRY }}/openfeedback-api:${{ steps.versions.outputs.api_version }}
98+
${{ env.REGISTRY }}/openfeedback-web:${{ steps.versions.outputs.web_version }}
99+
imagepullsecrets: acr-pull-secret
100+
101+
- name: Verify
102+
run: |
103+
kubectl rollout status deployment/openfeedback-api -n ${{ env.NAMESPACE }} --timeout=300s
104+
kubectl rollout status deployment/openfeedback-web -n ${{ env.NAMESPACE }} --timeout=300s
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: openfeedback-api
5+
namespace: canny
6+
labels:
7+
app: openfeedback-api
8+
spec:
9+
replicas: 1
10+
selector:
11+
matchLabels:
12+
app: openfeedback-api
13+
strategy:
14+
type: RollingUpdate
15+
rollingUpdate:
16+
maxSurge: 1
17+
maxUnavailable: 0
18+
template:
19+
metadata:
20+
labels:
21+
app: openfeedback-api
22+
spec:
23+
containers:
24+
- name: api
25+
image: techdomeacr.azurecr.io/openfeedback-api:_API_VERSION_
26+
imagePullPolicy: Always
27+
ports:
28+
- containerPort: 3000
29+
name: http
30+
env:
31+
- name: MONGODB_URI
32+
valueFrom:
33+
secretKeyRef:
34+
name: openfeedback-api-secrets
35+
key: MONGODB_URI
36+
- name: JWT_SECRET
37+
valueFrom:
38+
secretKeyRef:
39+
name: openfeedback-api-secrets
40+
key: JWT_SECRET
41+
- name: GOOGLE_CLIENT_ID
42+
valueFrom:
43+
secretKeyRef:
44+
name: openfeedback-api-secrets
45+
key: GOOGLE_CLIENT_ID
46+
optional: true
47+
- name: GOOGLE_CLIENT_SECRET
48+
valueFrom:
49+
secretKeyRef:
50+
name: openfeedback-api-secrets
51+
key: GOOGLE_CLIENT_SECRET
52+
optional: true
53+
- name: PORT
54+
value: "3000"
55+
- name: FRONTEND_URL
56+
value: "https://openfeedback.sparrowapp.dev"
57+
- name: NODE_ENV
58+
value: "development"
59+
livenessProbe:
60+
httpGet:
61+
path: /health
62+
port: 3000
63+
initialDelaySeconds: 30
64+
periodSeconds: 10
65+
readinessProbe:
66+
httpGet:
67+
path: /health
68+
port: 3000
69+
initialDelaySeconds: 5
70+
periodSeconds: 5
71+
resources:
72+
requests:
73+
memory: "256Mi"
74+
cpu: "250m"
75+
limits:
76+
memory: "512Mi"
77+
cpu: "500m"
78+
imagePullSecrets:
79+
- name: acr-pull-secret
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: openfeedback-web
5+
namespace: canny
6+
labels:
7+
app: openfeedback-web
8+
spec:
9+
replicas: 1
10+
selector:
11+
matchLabels:
12+
app: openfeedback-web
13+
strategy:
14+
type: RollingUpdate
15+
rollingUpdate:
16+
maxSurge: 1
17+
maxUnavailable: 0
18+
template:
19+
metadata:
20+
labels:
21+
app: openfeedback-web
22+
spec:
23+
containers:
24+
- name: web
25+
image: techdomeacr.azurecr.io/openfeedback-web:_WEB_VERSION_
26+
imagePullPolicy: Always
27+
ports:
28+
- containerPort: 80
29+
name: http
30+
livenessProbe:
31+
httpGet:
32+
path: /
33+
port: 80
34+
initialDelaySeconds: 10
35+
periodSeconds: 10
36+
readinessProbe:
37+
httpGet:
38+
path: /
39+
port: 80
40+
initialDelaySeconds: 5
41+
periodSeconds: 5
42+
resources:
43+
requests:
44+
memory: "64Mi"
45+
cpu: "100m"
46+
limits:
47+
memory: "256Mi"
48+
cpu: "200m"
49+
imagePullSecrets:
50+
- name: acr-pull-secret

0 commit comments

Comments
 (0)