@@ -65,40 +65,16 @@ jobs:
6565 MONGO_PASSWORD: $(echo -n "${{ secrets.MONGO_PASSWORD }}" | base64)
6666 EOF
6767
68- # - name: Generate Deployment YAML with Docker image
69- # run: |
70- # IMAGE_TAG=${{ inputs.image-tag || github.sha }}
71- # envsubst < ./kubernetes/deployment.template.yml > ./kubernetes/deployment.yml
72- # env:
73- # DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
74- # IMAGE_TAG: ${{ inputs.image-tag || github.sha }}
75-
76- - name : Setup helm
77- uses : azure/setup-helm@v4
78- with :
79- version : v3.5.4
80-
81-
82- - name : Deploy with helm
68+ - name : Update Helm values with new image tag
8369 run : |
8470 IMAGE_TAG=${{ inputs.image-tag || github.sha }}
85- helm upgrade --install solar-system ./helm \
86- --set image.repository=ghcr.io/${{ secrets.DOCKER_USERNAME }}/graduation-project-devops \
87- --set image.tag=$IMAGE_TAG \
88- --namespace default \
89- --create-namespace
90-
91- - name : Verify Deployment
92- run : |
93- kubectl get pods -l app=solar-system
94- kubectl get services
95- echo "Waiting for deployment to be ready..."
96- kubectl wait --for=condition=available --timeout=300s deployment/solar-system
97- echo "Waiting for container to be running..."
98- kubectl wait --for=condition=Ready --timeout=180s pod -l app=solar-system
99-
100- - name : Get Service URL
71+ # Update the image tag in values.yaml for ArgoCD to pick up
72+ sed -i "s|tag: \".*\"|tag: \"$IMAGE_TAG\"|g" ./helm/values.yaml
73+
74+ - name : Commit updated image tag
10175 run : |
102- HOSTNAME=$(kubectl get svc solar-system-svc -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')
103- echo "Service URL: http://$HOSTNAME"
104- working-directory : ./kubernetes
76+ git config --local user.email "[email protected] " 77+ git config --local user.name "GitHub Action"
78+ git add helm/values.yaml
79+ git commit -m "Update image tag to ${{ inputs.image-tag || github.sha }}" || exit 0
80+ git push
0 commit comments