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)"
0 commit comments