@@ -69,29 +69,33 @@ jobs:
6969 runs-on : self-hosted
7070
7171 steps :
72- - name : Checkout Helm Charts
72+ - name : Checkout main branch
7373 uses : actions/checkout@v4
74+ with :
75+ ref : main
76+ fetch-depth : 0
77+ token : ${{ secrets.GH_PAT }}
7478
7579 - name : Configure Git
7680 run : |
77- git config --global user.name "akhil27051999"
78- git config --global user.email "thyadiakhil@gmail.com"
79-
80- - name : Ensure main branch is up to date
81- run : git pull origin main
81+ git config user.name "akhil27051999"
82+ git config user.email "thyadiakhil@gmail.com"
8283
83- - name : Update image tag using sed
84+ - name : Update image tag in Helm values
8485 run : |
8586 echo "Updating image tag to $IMAGE_TAG..."
86- # Using sed - universal and reliable
87- sed -i 's/^\([[:space:]]*tag:[[:space:]]*\).*/\1'"$IMAGE_TAG"'/' ./ helm/application/values.yaml
87+ sed -i.bak "s|^\([[:space:]]*tag:[[:space:]]*\).*|\1$IMAGE_TAG|" helm/application/values.yaml
88+ rm -f helm/application/values.yaml.bak
8889 echo "Updated Helm values.yaml:"
89- cat ./ helm/application/values.yaml
90+ cat helm/application/values.yaml
9091 env :
9192 IMAGE_TAG : ${{ needs.build.outputs.image_tag }}
9293
93- - name : Commit and Push Changes
94+ - name : Commit and push
9495 run : |
95- git add ./helm/application/values.yaml
96- git commit -m "Update Flask App image tag to $IMAGE_TAG" || echo "No changes to commit"
97- git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git main
96+ git add helm/application/values.yaml
97+ git diff --cached --quiet && echo "No changes to commit" && exit 0
98+ git commit -m "ci: update flask-app image tag to $IMAGE_TAG [skip ci]"
99+ git push origin main
100+ env :
101+ IMAGE_TAG : ${{ needs.build.outputs.image_tag }}
0 commit comments