Skip to content

Commit 37937fb

Browse files
committed
updated pipeline to push new image tag to helm values
1 parent 67be4e4 commit 37937fb

1 file changed

Lines changed: 44 additions & 1 deletion

File tree

.github/workflows/ci-pipeline.yaml

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ on:
1818
jobs:
1919
build:
2020
runs-on: self-hosted
21+
22+
outputs:
23+
image_tag: ${{ steps.build-image.outputs.image_tag }}
24+
2125
steps:
2226
- name: Checkout Code
2327
uses: actions/checkout@v3
@@ -38,10 +42,12 @@ jobs:
3842
pytest -v
3943
4044
- name: Build Docker Image
45+
id: build-image
4146
run: |
4247
cd app
43-
IMAGE_TAG=${GITHUB_SHA::7} # short commit SHA
48+
IMAGE_TAG=${GITHUB_SHA::7}
4449
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
50+
echo "image_tag=$IMAGE_TAG" >> $GITHUB_OUTPUT
4551
docker build -t flask-app:$IMAGE_TAG .
4652
4753
- name: Login to Docker Hub
@@ -60,3 +66,40 @@ jobs:
6066
docker rmi flask-app:$IMAGE_TAG || true
6167
docker rmi ${{ secrets.DOCKER_HUB_USERNAME }}/flask-app:$IMAGE_TAG || true
6268
docker system prune -f || true
69+
70+
update-helm:
71+
needs: build
72+
runs-on: self-hosted
73+
74+
env:
75+
IMAGE_TAG: ${{ needs.build.outputs.image_tag }}
76+
77+
steps:
78+
- name: Checkout Helm Charts
79+
uses: actions/checkout@v3
80+
81+
- name: Configure Git
82+
run: |
83+
git config --global user.name "akhil27051999"
84+
git config --global user.email "thyadiakhil@gmail.com"
85+
86+
- name: Ensure main branch is up to date
87+
run: git pull origin main
88+
89+
- name: Install yq
90+
run: |
91+
sudo apt-get update -y
92+
sudo apt-get install -y yq
93+
94+
- name: Update Helm Chart with New Image Tag
95+
run: |
96+
echo "Updating image tag to $IMAGE_TAG..."
97+
yq e -i '.app.image.tag = strenv(IMAGE_TAG)' ./helm/application/values.yaml
98+
echo "Updated Helm values.yaml:"
99+
cat ./helm/application/values.yaml
100+
101+
- name: Commit and Push Changes
102+
run: |
103+
git add ./helm/application/values.yaml
104+
git commit -m "Update Flask App image tag to $IMAGE_TAG" || echo "No changes to commit"
105+
git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git main

0 commit comments

Comments
 (0)