Skip to content

Commit 7e239e2

Browse files
committed
Refactor deployment workflow to streamline Helm chart deployment and remove redundant environment variable definitions for MongoDB secrets
1 parent 6ac97cc commit 7e239e2

File tree

3 files changed

+19
-37
lines changed

3 files changed

+19
-37
lines changed

.github/workflows/deploy.yml

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
runs-on: ubuntu-latest
2828
environment: production
2929
permissions:
30-
contents: write # Allow writing to repository
30+
contents: write
3131
actions: read
3232

3333
steps:
@@ -53,25 +53,22 @@ jobs:
5353
region: us-east-1
5454
cluster: otel-cluster
5555

56-
57-
- name: Create Base64-encoded K8s Secret
56+
# ✅ Deploy Helm Chart with secrets & image tag
57+
- name: Deploy Helm Chart via ArgoCD
5858
run: |
59-
kubectl apply -f - <<EOF
60-
apiVersion: v1
61-
kind: Secret
62-
metadata:
63-
name: mongo-secrets
64-
type: Opaque
65-
data:
66-
MONGO_URI: $(echo -n "${{ secrets.MONGO_URI }}" | base64)
67-
MONGO_USERNAME: $(echo -n "${{ secrets.MONGO_USERNAME }}" | base64)
68-
MONGO_PASSWORD: $(echo -n "${{ secrets.MONGO_PASSWORD }}" | base64)
69-
EOF
59+
IMAGE_TAG=${{ inputs.image-tag || github.sha }}
60+
helm upgrade --install my-app ./helm \
61+
--namespace my-app-namespace \
62+
--create-namespace \
63+
--set mongo.uri="${{ secrets.MONGO_URI }}" \
64+
--set mongo.username="${{ secrets.MONGO_USERNAME }}" \
65+
--set mongo.password="${{ secrets.MONGO_PASSWORD }}" \
66+
--set image.tag="$IMAGE_TAG"
7067
68+
# ✅ Update values.yaml for ArgoCD tracking
7169
- name: Update Helm values with new image tag
7270
run: |
7371
IMAGE_TAG=${{ inputs.image-tag || github.sha }}
74-
# Update the image tag in values.yaml for ArgoCD to pick up
7572
sed -i "s|tag: \".*\"|tag: \"$IMAGE_TAG\"|g" ./helm/values.yaml
7673
7774
- name: Commit updated image tag
@@ -83,17 +80,18 @@ jobs:
8380
git push https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
8481
8582
- name: Create Application Namespace
86-
if: ${{ inputs.terraform-action == 'apply' || inputs.terraform-action == '' }}
8783
run: |
8884
kubectl create namespace my-app-namespace --dry-run=client -o yaml | kubectl apply -f -
8985
86+
# ✅ Deploy ArgoCD Application (optional if you want ArgoCD to track)
9087
- name: Deploy ArgoCD Applications
91-
if: ${{ inputs.terraform-action == 'apply' || inputs.terraform-action == '' }}
9288
run: |
9389
kubectl apply -f ./argocd/application.yml
9490
9591
- name: Print Service Endpoints
9692
run: |
93+
94+
GRAFANA_PASSWORD=${{secrets.GRAFANA_PASSWORD}}
9795
echo "================= SERVICE ENDPOINTS ================="
9896
echo "ArgoCD: http://$(kubectl get svc argocd-server -n argocd -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')"
9997
echo "Prometheus: http://$(kubectl get svc kube-prometheus-stack-prometheus -n monitoring -o jsonpath='{.status.loadBalancer.ingress[0].hostname}'):9090"
@@ -104,5 +102,5 @@ jobs:
104102
echo "ArgoCD -> Username: admin"
105103
echo "ArgoCD -> Password: $(kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath='{.data.password}' | base64 -d)"
106104
echo "Grafana -> Username: admin"
107-
echo "Grafana -> Password: $(kubectl get secret kube-prometheus-stack-grafana -n monitoring -o jsonpath='{.data.admin-password}' | base64 -d)"
105+
echo "Grafana -> Password: $GRAFANA_PASSWORD"
108106
echo "Prometheus -> No login needed (anonymous access by default)"

helm/templates/secrets.yaml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,3 @@ stringData:
88
MONGO_URI: {{ .Values.mongo.uri }}
99
MONGO_USERNAME: {{ .Values.mongo.username }}
1010
MONGO_PASSWORD: {{ .Values.mongo.password }}
11-
env:
12-
- name: MONGO_URI
13-
valueFrom:
14-
secretKeyRef:
15-
name: mongo-secrets
16-
key: MONGO_URI
17-
- name: MONGO_USERNAME
18-
valueFrom:
19-
secretKeyRef:
20-
name: mongo-secrets
21-
key: MONGO_USERNAME
22-
- name: MONGO_PASSWORD
23-
valueFrom:
24-
secretKeyRef:
25-
name: mongo-secrets
26-
key: MONGO_PASSWORD

helm/values.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ service:
1212
targetPort: 3000
1313

1414
mongo:
15-
uri: "YOUR_URI"
16-
username: "YOUR_USERNAME"
17-
password: "YOUR_PASSWORD"
15+
uri: ""
16+
username: ""
17+
password: ""

0 commit comments

Comments
 (0)