From e14e5ecc0e68369467bd815e2be7f7658dab5b17 Mon Sep 17 00:00:00 2001 From: sugesh-cloudops Date: Wed, 6 Aug 2025 12:15:06 +0200 Subject: [PATCH 01/18] "Update commit message in kustomize-ci workflow to include 'latest' in image tag update." --- .github/workflows/kustomize-ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/kustomize-ci.yaml b/.github/workflows/kustomize-ci.yaml index d72cfc5..a08ffa5 100644 --- a/.github/workflows/kustomize-ci.yaml +++ b/.github/workflows/kustomize-ci.yaml @@ -73,5 +73,5 @@ jobs: git config --global user.email ${{ secrets.GIT_USER_NAME }} git add kustomize/overlays/dev/patch-deployment-image.yaml - git commit -m "Update image tag to $IMAGE_TAG" + git commit -m "Update latest image tag to $IMAGE_TAG" git push \ No newline at end of file From b96be6f494f5d65b3101f7b50e322a0021c06d71 Mon Sep 17 00:00:00 2001 From: sugesh-cloudops Date: Wed, 6 Aug 2025 12:37:22 +0200 Subject: [PATCH 02/18] `Update GitHub Actions workflow to set GITHUB_TOKEN and modify git remote URL` --- .github/workflows/kustomize-ci.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/kustomize-ci.yaml b/.github/workflows/kustomize-ci.yaml index a08ffa5..2aaa19f 100644 --- a/.github/workflows/kustomize-ci.yaml +++ b/.github/workflows/kustomize-ci.yaml @@ -68,10 +68,15 @@ jobs: sed -i.bak -E "s|image:.*|image: ${IMAGE_NAME}:${IMAGE_TAG}|" "$FILE" - name: Commit and push changes + env: + GITHUB_TOKEN: ${{ secrets.GIT_PAT }} run: | git config --global user.name ${{ secrets.GIT_USER_EMAIL }} git config --global user.email ${{ secrets.GIT_USER_NAME }} + git remote set-url origin https://x-access-token:${TOKEN}@github.com/${{ github.repository }}.git + + git add kustomize/overlays/dev/patch-deployment-image.yaml git commit -m "Update latest image tag to $IMAGE_TAG" git push \ No newline at end of file From 49d60129bf2f211ae9a6f3737e4432247bcc8a5a Mon Sep 17 00:00:00 2001 From: sugesh-cloudops Date: Wed, 6 Aug 2025 14:01:36 +0200 Subject: [PATCH 03/18] `Update GitHub workflow to use GH_PAT and IMAGE_TAG instead of GIT_PAT` --- .github/workflows/kustomize-ci.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/kustomize-ci.yaml b/.github/workflows/kustomize-ci.yaml index 2aaa19f..f984c90 100644 --- a/.github/workflows/kustomize-ci.yaml +++ b/.github/workflows/kustomize-ci.yaml @@ -69,7 +69,8 @@ jobs: - name: Commit and push changes env: - GITHUB_TOKEN: ${{ secrets.GIT_PAT }} + TOKEN: ${{ secrets.GH_PAT }} + IMAGE_TAG: ${{ env.IMAGE_TAG }} run: | git config --global user.name ${{ secrets.GIT_USER_EMAIL }} git config --global user.email ${{ secrets.GIT_USER_NAME }} From 625a8ad0f7e4038c3dc30dbda53d4a21d586dd04 Mon Sep 17 00:00:00 2001 From: sugesh-cloudops Date: Wed, 6 Aug 2025 14:14:55 +0200 Subject: [PATCH 04/18] `Refactor kustomize-ci.yaml to remove update-kustomize job and merge its steps into build-and-push job` --- .github/workflows/kustomize-ci.yaml | 69 ++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 21 deletions(-) diff --git a/.github/workflows/kustomize-ci.yaml b/.github/workflows/kustomize-ci.yaml index f984c90..7b4e4a2 100644 --- a/.github/workflows/kustomize-ci.yaml +++ b/.github/workflows/kustomize-ci.yaml @@ -13,6 +13,7 @@ jobs: env: IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/springboot-postgres + IMAGE_TAG: ${{ needs.build-and-push.outputs.image-tag }} steps: - name: Checkout code @@ -45,33 +46,22 @@ jobs: docker build -t $IMAGE_NAME:$TAG ./app docker push $IMAGE_NAME:$TAG + - name: Checkout code + uses: actions/checkout@v4 - update-kustomize: - name: Update Kustomize Overlay - needs: build-and-push - runs-on: ubuntu-latest - - env: - IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/springboot-postgres - IMAGE_TAG: ${{ needs.build-and-push.outputs.image-tag }} - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Update image tag in dev overlay - run: | + - name: Update image tag in dev overlay + run: | FILE="kustomize/overlays/dev/patch-deployment-image.yaml" echo "Updating $FILE with image: $IMAGE_NAME:$IMAGE_TAG" sed -i.bak -E "s|image:.*|image: ${IMAGE_NAME}:${IMAGE_TAG}|" "$FILE" - - name: Commit and push changes - env: - TOKEN: ${{ secrets.GH_PAT }} - IMAGE_TAG: ${{ env.IMAGE_TAG }} - run: | + - name: Commit and push changes + env: + TOKEN: ${{ secrets.GH_PAT }} + IMAGE_TAG: ${{ env.IMAGE_TAG }} + run: | git config --global user.name ${{ secrets.GIT_USER_EMAIL }} git config --global user.email ${{ secrets.GIT_USER_NAME }} @@ -80,4 +70,41 @@ jobs: git add kustomize/overlays/dev/patch-deployment-image.yaml git commit -m "Update latest image tag to $IMAGE_TAG" - git push \ No newline at end of file + git push + + + # update-kustomize: + # name: Update Kustomize Overlay + # needs: build-and-push + # runs-on: ubuntu-latest + + # env: + # IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/springboot-postgres + # IMAGE_TAG: ${{ needs.build-and-push.outputs.image-tag }} + + # steps: + # - name: Checkout code + # uses: actions/checkout@v4 + + # - name: Update image tag in dev overlay + # run: | + # FILE="kustomize/overlays/dev/patch-deployment-image.yaml" + + # echo "Updating $FILE with image: $IMAGE_NAME:$IMAGE_TAG" + + # sed -i.bak -E "s|image:.*|image: ${IMAGE_NAME}:${IMAGE_TAG}|" "$FILE" + + # - name: Commit and push changes + # env: + # TOKEN: ${{ secrets.GH_PAT }} + # IMAGE_TAG: ${{ env.IMAGE_TAG }} + # run: | + # git config --global user.name ${{ secrets.GIT_USER_EMAIL }} + # git config --global user.email ${{ secrets.GIT_USER_NAME }} + + # git remote set-url origin https://x-access-token:${TOKEN}@github.com/${{ github.repository }}.git + + + # git add kustomize/overlays/dev/patch-deployment-image.yaml + # git commit -m "Update latest image tag to $IMAGE_TAG" + # git push \ No newline at end of file From 9d8abdbcac3b43766a0efe98d7dfe4b81feb958f Mon Sep 17 00:00:00 2001 From: sugesh-cloudops Date: Wed, 6 Aug 2025 14:29:03 +0200 Subject: [PATCH 05/18] `Update GitHub Actions workflow to use GH_PAT secret instead of TOKEN` --- .github/workflows/kustomize-ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/kustomize-ci.yaml b/.github/workflows/kustomize-ci.yaml index 7b4e4a2..253cd3e 100644 --- a/.github/workflows/kustomize-ci.yaml +++ b/.github/workflows/kustomize-ci.yaml @@ -65,7 +65,7 @@ jobs: git config --global user.name ${{ secrets.GIT_USER_EMAIL }} git config --global user.email ${{ secrets.GIT_USER_NAME }} - git remote set-url origin https://x-access-token:${TOKEN}@github.com/${{ github.repository }}.git + git remote set-url origin https://x-access-token:${{ secrets.GH_PAT }}@github.com/${{ github.repository }}.git git add kustomize/overlays/dev/patch-deployment-image.yaml From f85bc0711a92bfbd0f7be39065e035b0e385fabe Mon Sep 17 00:00:00 2001 From: sugesh-cloudops Date: Wed, 6 Aug 2025 14:36:55 +0200 Subject: [PATCH 06/18] `Update git config and remote URL in kustomize-ci workflow` --- .github/workflows/kustomize-ci.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/kustomize-ci.yaml b/.github/workflows/kustomize-ci.yaml index 253cd3e..ecaa3b7 100644 --- a/.github/workflows/kustomize-ci.yaml +++ b/.github/workflows/kustomize-ci.yaml @@ -62,10 +62,11 @@ jobs: TOKEN: ${{ secrets.GH_PAT }} IMAGE_TAG: ${{ env.IMAGE_TAG }} run: | - git config --global user.name ${{ secrets.GIT_USER_EMAIL }} - git config --global user.email ${{ secrets.GIT_USER_NAME }} + git config --global user.name "${{ secrets.GIT_USER_NAME }}" + git config --global user.email "${{ secrets.GIT_USER_EMAIL }}" git remote set-url origin https://x-access-token:${{ secrets.GH_PAT }}@github.com/${{ github.repository }}.git + git remote set-url origin https://x-access-token:${{ secrets.GH_PAT }}@github.com/${{ github.repository }}.git git add kustomize/overlays/dev/patch-deployment-image.yaml From 68be98baff58cc6508b03e35ae3b3df6ba66bb85 Mon Sep 17 00:00:00 2001 From: sugesh-cloudops Date: Wed, 6 Aug 2025 14:57:37 +0200 Subject: [PATCH 07/18] `Refactor GitHub Actions workflow for updating Kustomize overlay` --- .github/workflows/kustomize-ci.yaml | 67 +++++++++++------------------ 1 file changed, 25 insertions(+), 42 deletions(-) diff --git a/.github/workflows/kustomize-ci.yaml b/.github/workflows/kustomize-ci.yaml index ecaa3b7..d0d05b7 100644 --- a/.github/workflows/kustomize-ci.yaml +++ b/.github/workflows/kustomize-ci.yaml @@ -57,55 +57,38 @@ jobs: sed -i.bak -E "s|image:.*|image: ${IMAGE_NAME}:${IMAGE_TAG}|" "$FILE" - - name: Commit and push changes - env: - TOKEN: ${{ secrets.GH_PAT }} - IMAGE_TAG: ${{ env.IMAGE_TAG }} - run: | - git config --global user.name "${{ secrets.GIT_USER_NAME }}" - git config --global user.email "${{ secrets.GIT_USER_EMAIL }}" - - git remote set-url origin https://x-access-token:${{ secrets.GH_PAT }}@github.com/${{ github.repository }}.git - git remote set-url origin https://x-access-token:${{ secrets.GH_PAT }}@github.com/${{ github.repository }}.git - - - git add kustomize/overlays/dev/patch-deployment-image.yaml - git commit -m "Update latest image tag to $IMAGE_TAG" - git push + update-kustomize: + name: Update Kustomize Overlay + needs: build-and-push + runs-on: ubuntu-latest - # update-kustomize: - # name: Update Kustomize Overlay - # needs: build-and-push - # runs-on: ubuntu-latest + env: + IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/springboot-postgres + IMAGE_TAG: ${{ needs.build-and-push.outputs.image-tag }} - # env: - # IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/springboot-postgres - # IMAGE_TAG: ${{ needs.build-and-push.outputs.image-tag }} + steps: + - name: Checkout code + uses: actions/checkout@v4 - # steps: - # - name: Checkout code - # uses: actions/checkout@v4 - - # - name: Update image tag in dev overlay - # run: | - # FILE="kustomize/overlays/dev/patch-deployment-image.yaml" + - name: Update image tag in dev overlay + run: | + FILE="kustomize/overlays/dev/patch-deployment-image.yaml" - # echo "Updating $FILE with image: $IMAGE_NAME:$IMAGE_TAG" + echo "Updating $FILE with image: $IMAGE_NAME:$IMAGE_TAG" - # sed -i.bak -E "s|image:.*|image: ${IMAGE_NAME}:${IMAGE_TAG}|" "$FILE" + sed -i.bak -E "s|image:.*|image: ${IMAGE_NAME}:${IMAGE_TAG}|" "$FILE" - # - name: Commit and push changes - # env: - # TOKEN: ${{ secrets.GH_PAT }} - # IMAGE_TAG: ${{ env.IMAGE_TAG }} - # run: | - # git config --global user.name ${{ secrets.GIT_USER_EMAIL }} - # git config --global user.email ${{ secrets.GIT_USER_NAME }} + - name: Commit and push changes + run: | + git config --global user.name "${{ secrets.GIT_USER_NAME }}" + git config --global user.email "${{ secrets.GIT_USER_EMAIL }}" - # git remote set-url origin https://x-access-token:${TOKEN}@github.com/${{ github.repository }}.git + git remote set-url origin https://x-access-token:${{ secrets.GH_PAT }}@github.com/${{ github.repository }}.git - # git add kustomize/overlays/dev/patch-deployment-image.yaml - # git commit -m "Update latest image tag to $IMAGE_TAG" - # git push \ No newline at end of file + git add kustomize/overlays/dev/patch-deployment-image.yaml + git commit -m "Update latest image tag to $IMAGE_TAG" || echo "No changes to commit" + git push + env: + IMAGE_TAG: ${{ github.sha }} \ No newline at end of file From 01ed870699c89f34111fa39ba013c2b7c7b9c02e Mon Sep 17 00:00:00 2001 From: sugesh-cloudops Date: Wed, 6 Aug 2025 15:08:37 +0200 Subject: [PATCH 08/18] "Removed Build and Push Docker Image steps in kustomize-ci workflow" --- .github/workflows/kustomize-ci.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/kustomize-ci.yaml b/.github/workflows/kustomize-ci.yaml index d0d05b7..de7f105 100644 --- a/.github/workflows/kustomize-ci.yaml +++ b/.github/workflows/kustomize-ci.yaml @@ -38,14 +38,14 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and Push Docker Image - run: | - COMMIT_SHA=$(echo "${{ github.sha }}" | cut -c1-7) - BRANCH=$(echo "${GITHUB_REF#refs/heads/}" | tr '/' '-') - TAG="${BRANCH}-${COMMIT_SHA}" + # - name: Build and Push Docker Image + # run: | + # COMMIT_SHA=$(echo "${{ github.sha }}" | cut -c1-7) + # BRANCH=$(echo "${GITHUB_REF#refs/heads/}" | tr '/' '-') + # TAG="${BRANCH}-${COMMIT_SHA}" - docker build -t $IMAGE_NAME:$TAG ./app - docker push $IMAGE_NAME:$TAG + # docker build -t $IMAGE_NAME:$TAG ./app + # docker push $IMAGE_NAME:$TAG - name: Checkout code uses: actions/checkout@v4 From e5b906f70ae2d9911630a1f85d56555259efd478 Mon Sep 17 00:00:00 2001 From: sugesh-cloudops Date: Wed, 6 Aug 2025 15:19:12 +0200 Subject: [PATCH 09/18] `Update kustomize-ci workflow to configure git credentials and update image tag in dev overlay` --- .github/workflows/kustomize-ci.yaml | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/.github/workflows/kustomize-ci.yaml b/.github/workflows/kustomize-ci.yaml index de7f105..2cdfe45 100644 --- a/.github/workflows/kustomize-ci.yaml +++ b/.github/workflows/kustomize-ci.yaml @@ -71,6 +71,11 @@ jobs: - name: Checkout code uses: actions/checkout@v4 + - name: Configure git + run: | + git config --global user.name "${{ secrets.GIT_USER_NAME }}" + git config --global user.email "${{ secrets.GIT_USER_EMAIL }}" + - name: Update image tag in dev overlay run: | FILE="kustomize/overlays/dev/patch-deployment-image.yaml" @@ -79,16 +84,20 @@ jobs: sed -i.bak -E "s|image:.*|image: ${IMAGE_NAME}:${IMAGE_TAG}|" "$FILE" - - name: Commit and push changes - run: | - git config --global user.name "${{ secrets.GIT_USER_NAME }}" - git config --global user.email "${{ secrets.GIT_USER_EMAIL }}" + git add "$FILE" + git commit -m "Update image tag to $IMAGE_TAG in kustomize overlay" + git push origin HEAD:feature/kustomize-update + + # - name: Commit and push changes + # run: | + # git config --global user.name "${{ secrets.GIT_USER_NAME }}" + # git config --global user.email "${{ secrets.GIT_USER_EMAIL }}" - git remote set-url origin https://x-access-token:${{ secrets.GH_PAT }}@github.com/${{ github.repository }}.git + # git remote set-url origin https://x-access-token:${{ secrets.GH_PAT }}@github.com/${{ github.repository }}.git - git add kustomize/overlays/dev/patch-deployment-image.yaml - git commit -m "Update latest image tag to $IMAGE_TAG" || echo "No changes to commit" - git push - env: - IMAGE_TAG: ${{ github.sha }} \ No newline at end of file + # git add kustomize/overlays/dev/patch-deployment-image.yaml + # git commit -m "Update latest image tag to $IMAGE_TAG" || echo "No changes to commit" + # git push + # env: + # IMAGE_TAG: ${{ github.sha }} \ No newline at end of file From db31909572823c36a9ed1b8e487864f5ccae4f42 Mon Sep 17 00:00:00 2001 From: sugesh-cloudops Date: Wed, 6 Aug 2025 15:30:53 +0200 Subject: [PATCH 10/18] `Update .github/workflows/kustomize-ci.yaml to include feature/development branch and restore removed steps` --- .github/workflows/kustomize-ci.yaml | 30 +++++++++-------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/.github/workflows/kustomize-ci.yaml b/.github/workflows/kustomize-ci.yaml index 2cdfe45..54dcfc9 100644 --- a/.github/workflows/kustomize-ci.yaml +++ b/.github/workflows/kustomize-ci.yaml @@ -3,7 +3,7 @@ name: Kustomize CI - Build and Push on: push: branches: - - feature/** + - feature/development - development jobs: @@ -38,14 +38,14 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - # - name: Build and Push Docker Image - # run: | - # COMMIT_SHA=$(echo "${{ github.sha }}" | cut -c1-7) - # BRANCH=$(echo "${GITHUB_REF#refs/heads/}" | tr '/' '-') - # TAG="${BRANCH}-${COMMIT_SHA}" + - name: Build and Push Docker Image + run: | + COMMIT_SHA=$(echo "${{ github.sha }}" | cut -c1-7) + BRANCH=$(echo "${GITHUB_REF#refs/heads/}" | tr '/' '-') + TAG="${BRANCH}-${COMMIT_SHA}" - # docker build -t $IMAGE_NAME:$TAG ./app - # docker push $IMAGE_NAME:$TAG + docker build -t $IMAGE_NAME:$TAG ./app + docker push $IMAGE_NAME:$TAG - name: Checkout code uses: actions/checkout@v4 @@ -88,16 +88,4 @@ jobs: git commit -m "Update image tag to $IMAGE_TAG in kustomize overlay" git push origin HEAD:feature/kustomize-update - # - name: Commit and push changes - # run: | - # git config --global user.name "${{ secrets.GIT_USER_NAME }}" - # git config --global user.email "${{ secrets.GIT_USER_EMAIL }}" - - - # git remote set-url origin https://x-access-token:${{ secrets.GH_PAT }}@github.com/${{ github.repository }}.git - - # git add kustomize/overlays/dev/patch-deployment-image.yaml - # git commit -m "Update latest image tag to $IMAGE_TAG" || echo "No changes to commit" - # git push - # env: - # IMAGE_TAG: ${{ github.sha }} \ No newline at end of file + \ No newline at end of file From 0347a31b8421a36e5353b9ad2549015542a92fc5 Mon Sep 17 00:00:00 2001 From: sugesh-cloudops Date: Wed, 6 Aug 2025 15:36:21 +0200 Subject: [PATCH 11/18] "Added git pull and rebase to kustomize-ci workflow and added newline at end of file" --- .github/workflows/kustomize-ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/kustomize-ci.yaml b/.github/workflows/kustomize-ci.yaml index 54dcfc9..bfe9e2c 100644 --- a/.github/workflows/kustomize-ci.yaml +++ b/.github/workflows/kustomize-ci.yaml @@ -86,6 +86,8 @@ jobs: git add "$FILE" git commit -m "Update image tag to $IMAGE_TAG in kustomize overlay" + + git pull origin feature/kustomize-update --rebase git push origin HEAD:feature/kustomize-update \ No newline at end of file From 138ab6f3c5296f234418339a2fa5734d7b425a7d Mon Sep 17 00:00:00 2001 From: sugesh-cloudops Date: Wed, 6 Aug 2025 15:46:02 +0200 Subject: [PATCH 12/18] `Update CI workflow to use git rebase and force-push to auto/kustomize-update branch` --- .github/workflows/kustomize-ci.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/kustomize-ci.yaml b/.github/workflows/kustomize-ci.yaml index bfe9e2c..fefef85 100644 --- a/.github/workflows/kustomize-ci.yaml +++ b/.github/workflows/kustomize-ci.yaml @@ -87,7 +87,8 @@ jobs: git add "$FILE" git commit -m "Update image tag to $IMAGE_TAG in kustomize overlay" - git pull origin feature/kustomize-update --rebase - git push origin HEAD:feature/kustomize-update + git rebase --abort || true + git push origin HEAD:auto/kustomize-update --force-with-lease + \ No newline at end of file From 759bbf8c298d35712010eb26289af315276ed527 Mon Sep 17 00:00:00 2001 From: sugesh-cloudops Date: Wed, 6 Aug 2025 16:07:13 +0200 Subject: [PATCH 13/18] `Refactor GitHub Actions workflow for kustomize-ci.yaml` This commit refactors the GitHub Actions workflow for kustomize-ci.yaml by: - Moving the image tag setting to a separate step - Renaming the "Build and Push Docker Image --- .github/workflows/kustomize-ci.yaml | 71 ++++++++++++++--------------- 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/.github/workflows/kustomize-ci.yaml b/.github/workflows/kustomize-ci.yaml index fefef85..b92613d 100644 --- a/.github/workflows/kustomize-ci.yaml +++ b/.github/workflows/kustomize-ci.yaml @@ -13,7 +13,9 @@ jobs: env: IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/springboot-postgres - IMAGE_TAG: ${{ needs.build-and-push.outputs.image-tag }} + + outputs: + image-tag: ${{ steps.set-tag.outputs.tag }} steps: - name: Checkout code @@ -38,57 +40,54 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and Push Docker Image + - name: Set Image Tag + id: set-tag run: | COMMIT_SHA=$(echo "${{ github.sha }}" | cut -c1-7) BRANCH=$(echo "${GITHUB_REF#refs/heads/}" | tr '/' '-') TAG="${BRANCH}-${COMMIT_SHA}" - - docker build -t $IMAGE_NAME:$TAG ./app - docker push $IMAGE_NAME:$TAG - - name: Checkout code - uses: actions/checkout@v4 + echo "tag=$TAG" >> $GITHUB_OUTPUT - - name: Update image tag in dev overlay + - name: Build and Push Docker Image run: | - FILE="kustomize/overlays/dev/patch-deployment-image.yaml" - - echo "Updating $FILE with image: $IMAGE_NAME:$IMAGE_TAG" - - sed -i.bak -E "s|image:.*|image: ${IMAGE_NAME}:${IMAGE_TAG}|" "$FILE" - + docker build -t $IMAGE_NAME:${{ steps.set-tag.outputs.tag }} ./app + docker push $IMAGE_NAME:${{ steps.set-tag.outputs.tag }} update-kustomize: - name: Update Kustomize Overlay - needs: build-and-push - runs-on: ubuntu-latest + name: Update Kustomize Overlay + needs: build-and-push + runs-on: ubuntu-latest - env: - IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/springboot-postgres - IMAGE_TAG: ${{ needs.build-and-push.outputs.image-tag }} + env: + IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/springboot-postgres + IMAGE_TAG: ${{ needs.build-and-push.outputs.image-tag }} - steps: - - name: Checkout code - uses: actions/checkout@v4 + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Configure git + run: | + git config --global user.name "${{ secrets.GIT_USER_NAME }}" + git config --global user.email "${{ secrets.GIT_USER_EMAIL }}" - - name: Configure git - run: | - git config --global user.name "${{ secrets.GIT_USER_NAME }}" - git config --global user.email "${{ secrets.GIT_USER_EMAIL }}" + - name: Update image tag + run: | + if [ -z "$IMAGE_TAG" ]; then + echo " IMAGE_TAG is empty, exiting." + exit 1 + fi - - name: Update image tag in dev overlay - run: | - FILE="kustomize/overlays/dev/patch-deployment-image.yaml" + FILE="kustomize/overlays/dev/patch-deployment-image.yaml" + echo "Updating $FILE with image: $IMAGE_NAME:$IMAGE_TAG" - echo "Updating $FILE with image: $IMAGE_NAME:$IMAGE_TAG" + sed -i.bak -E "s|image:.*|image: ${IMAGE_NAME}:${IMAGE_TAG}|" "$FILE" - sed -i.bak -E "s|image:.*|image: ${IMAGE_NAME}:${IMAGE_TAG}|" "$FILE" + git add "$FILE" + git commit -m "Update image tag to $IMAGE_TAG" + git push origin HEAD:auto/kustomize-update --force-with-lease - git add "$FILE" - git commit -m "Update image tag to $IMAGE_TAG in kustomize overlay" - git rebase --abort || true - git push origin HEAD:auto/kustomize-update --force-with-lease \ No newline at end of file From d7ec36ab10d73123c740765454901cad55134b5b Mon Sep 17 00:00:00 2001 From: sugesh-cloudops Date: Wed, 6 Aug 2025 16:13:39 +0200 Subject: [PATCH 14/18] "Added git pull and rebase to kustomize-ci workflow" --- .github/workflows/kustomize-ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/kustomize-ci.yaml b/.github/workflows/kustomize-ci.yaml index b92613d..1e83f22 100644 --- a/.github/workflows/kustomize-ci.yaml +++ b/.github/workflows/kustomize-ci.yaml @@ -85,6 +85,8 @@ jobs: git add "$FILE" git commit -m "Update image tag to $IMAGE_TAG" + + git pull origin auto/kustomize-update --rebase || true git push origin HEAD:auto/kustomize-update --force-with-lease From 32a479aa1b29f40b7e04111f194756bc7c0bec36 Mon Sep 17 00:00:00 2001 From: sugesh-cloudops Date: Wed, 6 Aug 2025 16:45:26 +0200 Subject: [PATCH 15/18] "Removed development branch from push event and removed git pull command in kustomize-ci workflow." --- .github/workflows/kustomize-ci.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/kustomize-ci.yaml b/.github/workflows/kustomize-ci.yaml index 1e83f22..3e3c6ba 100644 --- a/.github/workflows/kustomize-ci.yaml +++ b/.github/workflows/kustomize-ci.yaml @@ -4,7 +4,7 @@ on: push: branches: - feature/development - - development + # - development jobs: build-and-push: @@ -86,7 +86,6 @@ jobs: git add "$FILE" git commit -m "Update image tag to $IMAGE_TAG" - git pull origin auto/kustomize-update --rebase || true git push origin HEAD:auto/kustomize-update --force-with-lease From 241803aa87dd01218352d9232785fa52ae27f6da Mon Sep 17 00:00:00 2001 From: sugesh-cloudops Date: Wed, 6 Aug 2025 16:56:03 +0200 Subject: [PATCH 16/18] `Update image tag and push to branch in kustomize-ci workflow` --- .github/workflows/kustomize-ci.yaml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/kustomize-ci.yaml b/.github/workflows/kustomize-ci.yaml index 3e3c6ba..63c9e44 100644 --- a/.github/workflows/kustomize-ci.yaml +++ b/.github/workflows/kustomize-ci.yaml @@ -71,24 +71,29 @@ jobs: git config --global user.name "${{ secrets.GIT_USER_NAME }}" git config --global user.email "${{ secrets.GIT_USER_EMAIL }}" - - name: Update image tag + - name: Update image tag and push to branch run: | if [ -z "$IMAGE_TAG" ]; then - echo " IMAGE_TAG is empty, exiting." + echo "IMAGE_TAG is empty, exiting." exit 1 fi + git fetch origin auto/kustomize-update || true + git pull origin auto/kustomize-update --rebase || true + FILE="kustomize/overlays/dev/patch-deployment-image.yaml" echo "Updating $FILE with image: $IMAGE_NAME:$IMAGE_TAG" sed -i.bak -E "s|image:.*|image: ${IMAGE_NAME}:${IMAGE_TAG}|" "$FILE" git add "$FILE" - git commit -m "Update image tag to $IMAGE_TAG" - - git push origin HEAD:auto/kustomize-update --force-with-lease + git commit -m "Update image tag to $IMAGE_TAG" || echo "No changes to commit" + git push origin HEAD:auto/kustomize-update --force-with-lease + env: + IMAGE_NAME: yourdockerhub/springboot-postgres + IMAGE_TAG: ${{ needs.build-and-push.outputs.image-tag }} \ No newline at end of file From 4505d27743795eecff4ddb0921cd08a76a5c0d1d Mon Sep 17 00:00:00 2001 From: sugesh-cloudops Date: Wed, 6 Aug 2025 17:01:44 +0200 Subject: [PATCH 17/18] `Added concurrency control and minor formatting changes to kustomize-ci.yaml workflow file.` --- .github/workflows/kustomize-ci.yaml | 34 ++++++++++++----------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/.github/workflows/kustomize-ci.yaml b/.github/workflows/kustomize-ci.yaml index 63c9e44..39e9ee4 100644 --- a/.github/workflows/kustomize-ci.yaml +++ b/.github/workflows/kustomize-ci.yaml @@ -4,19 +4,23 @@ on: push: branches: - feature/development - # - development + - development + +concurrency: + group: kustomize-update + cancel-in-progress: true jobs: build-and-push: name: Build and Push Docker Image runs-on: ubuntu-latest - env: - IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/springboot-postgres - outputs: image-tag: ${{ steps.set-tag.outputs.tag }} + env: + IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/springboot-postgres + steps: - name: Checkout code uses: actions/checkout@v4 @@ -40,15 +44,15 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Set Image Tag + - name: Set image tag id: set-tag run: | COMMIT_SHA=$(echo "${{ github.sha }}" | cut -c1-7) BRANCH=$(echo "${GITHUB_REF#refs/heads/}" | tr '/' '-') TAG="${BRANCH}-${COMMIT_SHA}" - echo "tag=$TAG" >> $GITHUB_OUTPUT + echo "tag=$TAG" >> "$GITHUB_OUTPUT" - - name: Build and Push Docker Image + - name: Build and push Docker image run: | docker build -t $IMAGE_NAME:${{ steps.set-tag.outputs.tag }} ./app docker push $IMAGE_NAME:${{ steps.set-tag.outputs.tag }} @@ -73,27 +77,17 @@ jobs: - name: Update image tag and push to branch run: | - if [ -z "$IMAGE_TAG" ]; then - echo "IMAGE_TAG is empty, exiting." - exit 1 - fi - - git fetch origin auto/kustomize-update || true - git pull origin auto/kustomize-update --rebase || true - FILE="kustomize/overlays/dev/patch-deployment-image.yaml" + echo "Updating $FILE with image: $IMAGE_NAME:$IMAGE_TAG" sed -i.bak -E "s|image:.*|image: ${IMAGE_NAME}:${IMAGE_TAG}|" "$FILE" + git checkout -B auto/kustomize-update git add "$FILE" git commit -m "Update image tag to $IMAGE_TAG" || echo "No changes to commit" - - git push origin HEAD:auto/kustomize-update --force-with-lease - env: - IMAGE_NAME: yourdockerhub/springboot-postgres - IMAGE_TAG: ${{ needs.build-and-push.outputs.image-tag }} + git push origin auto/kustomize-update --force \ No newline at end of file From a6ba9a3fac39d90d438cf86f1712ce7d664aaa3f Mon Sep 17 00:00:00 2001 From: sugesh-cloudops Date: Wed, 6 Aug 2025 17:12:59 +0200 Subject: [PATCH 18/18] `Refactor GitHub Actions workflow for Helm CI: Update Docker image tag and Helm values.yaml` --- .github/workflows/helm-ci.yaml | 164 ++++++++++++++++----------------- 1 file changed, 82 insertions(+), 82 deletions(-) diff --git a/.github/workflows/helm-ci.yaml b/.github/workflows/helm-ci.yaml index 89512bf..777e1b0 100644 --- a/.github/workflows/helm-ci.yaml +++ b/.github/workflows/helm-ci.yaml @@ -1,82 +1,82 @@ -# name: Helm CI - Build and Update Values.yaml - -# on: -# push: -# branches: -# - main - -# jobs: -# build-and-push: -# name: Build and Push Docker Image -# runs-on: ubuntu-latest - -# outputs: -# image-tag: ${{ steps.meta.outputs.image-tag }} - -# env: -# IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/springboot-postgres - -# steps: -# - name: Checkout code -# uses: actions/checkout@v4 - -# - name: Set up JDK 17 -# uses: actions/setup-java@v4 -# with: -# distribution: 'temurin' -# java-version: '17' - -# - name: Build Spring Boot App -# working-directory: ./app -# run: ./mvnw clean package -DskipTests - -# - name: Set up Docker Buildx -# uses: docker/setup-buildx-action@v3 - -# - name: Login to DockerHub -# uses: docker/login-action@v3 -# with: -# username: ${{ secrets.DOCKERHUB_USERNAME }} -# password: ${{ secrets.DOCKERHUB_TOKEN }} - -# - name: Build and Push Docker Image -# id: meta -# run: | -# COMMIT_SHA=$(echo "${{ github.sha }}" | cut -c1-7) -# IMAGE_TAG="main-${COMMIT_SHA}" - -# echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV -# echo "::set-output name=image-tag::$IMAGE_TAG" - -# docker build -t $IMAGE_NAME:$IMAGE_TAG ./app -# docker push $IMAGE_NAME:$IMAGE_TAG - -# update-helm-values: -# name: Update Helm Values -# needs: build-and-push -# runs-on: ubuntu-latest - -# env: -# IMAGE_TAG: ${{ needs.build-and-push.outputs.image-tag }} -# IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/springboot-postgres - -# steps: -# - name: Checkout code -# uses: actions/checkout@v4 - -# - name: Update image.tag in values.yaml -# run: | -# FILE="helm/springboot-postgres-prod/values.yaml" -# echo "Updating $FILE with image tag $IMAGE_TAG" - -# # Replace the image tag line -# sed -i.bak -E "s|tag:.*|tag: \"$IMAGE_TAG\"|" "$FILE" - -# - name: Commit and Push changes -# run: | -# git config --global user.name "github-actions" -# git config --global user.email "github-actions@github.com" - -# git add helm/springboot-postgres-prod/values.yaml -# git commit -m "Update Helm image tag to $IMAGE_TAG" -# git push \ No newline at end of file +name: Helm CI - Build and Push + +on: + push: + branches: + - main + +jobs: + build-and-push: + name: Build and Push Docker Image + runs-on: ubuntu-latest + + outputs: + image-tag: ${{ steps.set-tag.outputs.tag }} + + env: + IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/springboot-postgres + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '17' + + - name: Build Spring Boot App + working-directory: ./app + run: ./mvnw clean package -DskipTests + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Set Image Tag + id: set-tag + run: | + COMMIT_SHA=$(echo "${{ github.sha }}" | cut -c1-7) + TAG="main-${COMMIT_SHA}" + echo "tag=$TAG" >> $GITHUB_OUTPUT + + - name: Build and Push Docker Image + run: | + docker build -t $IMAGE_NAME:${{ steps.set-tag.outputs.tag }} ./app + docker push $IMAGE_NAME:${{ steps.set-tag.outputs.tag }} + + update-values: + name: Update Helm values.yaml + needs: build-and-push + runs-on: ubuntu-latest + + env: + IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/springboot-postgres + IMAGE_TAG: ${{ needs.build-and-push.outputs.image-tag }} + FILE: helm/springboot-postgres-prod/values.yaml + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Configure Git + run: | + git config --global user.name "${{ secrets.GIT_USER_NAME }}" + git config --global user.email "${{ secrets.GIT_USER_EMAIL }}" + + - name: Update values.yaml + run: | + echo "Updating $FILE with image: $IMAGE_NAME:$IMAGE_TAG" + sed -i.bak -E "s|image:.*|image: ${IMAGE_NAME}:${IMAGE_TAG}|" "$FILE" + + git add "$FILE" + git commit -m "Update image tag to $IMAGE_TAG in Helm values.yaml" + + git pull origin auto/helm-update --rebase || true + git push origin HEAD:auto/helm-update-prod --force-with-lease \ No newline at end of file