Skip to content

Commit 4505d27

Browse files
Added concurrency control and minor formatting changes to kustomize-ci.yaml workflow file.
1 parent 241803a commit 4505d27

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

.github/workflows/kustomize-ci.yaml

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,23 @@ on:
44
push:
55
branches:
66
- feature/development
7-
# - development
7+
- development
8+
9+
concurrency:
10+
group: kustomize-update
11+
cancel-in-progress: true
812

913
jobs:
1014
build-and-push:
1115
name: Build and Push Docker Image
1216
runs-on: ubuntu-latest
1317

14-
env:
15-
IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/springboot-postgres
16-
1718
outputs:
1819
image-tag: ${{ steps.set-tag.outputs.tag }}
1920

21+
env:
22+
IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/springboot-postgres
23+
2024
steps:
2125
- name: Checkout code
2226
uses: actions/checkout@v4
@@ -40,15 +44,15 @@ jobs:
4044
username: ${{ secrets.DOCKERHUB_USERNAME }}
4145
password: ${{ secrets.DOCKERHUB_TOKEN }}
4246

43-
- name: Set Image Tag
47+
- name: Set image tag
4448
id: set-tag
4549
run: |
4650
COMMIT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
4751
BRANCH=$(echo "${GITHUB_REF#refs/heads/}" | tr '/' '-')
4852
TAG="${BRANCH}-${COMMIT_SHA}"
49-
echo "tag=$TAG" >> $GITHUB_OUTPUT
53+
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
5054
51-
- name: Build and Push Docker Image
55+
- name: Build and push Docker image
5256
run: |
5357
docker build -t $IMAGE_NAME:${{ steps.set-tag.outputs.tag }} ./app
5458
docker push $IMAGE_NAME:${{ steps.set-tag.outputs.tag }}
@@ -73,27 +77,17 @@ jobs:
7377
7478
- name: Update image tag and push to branch
7579
run: |
76-
if [ -z "$IMAGE_TAG" ]; then
77-
echo "IMAGE_TAG is empty, exiting."
78-
exit 1
79-
fi
80-
81-
git fetch origin auto/kustomize-update || true
82-
git pull origin auto/kustomize-update --rebase || true
83-
8480
FILE="kustomize/overlays/dev/patch-deployment-image.yaml"
81+
8582
echo "Updating $FILE with image: $IMAGE_NAME:$IMAGE_TAG"
8683
8784
sed -i.bak -E "s|image:.*|image: ${IMAGE_NAME}:${IMAGE_TAG}|" "$FILE"
8885
86+
git checkout -B auto/kustomize-update
8987
git add "$FILE"
9088
git commit -m "Update image tag to $IMAGE_TAG" || echo "No changes to commit"
9189
92-
93-
git push origin HEAD:auto/kustomize-update --force-with-lease
94-
env:
95-
IMAGE_NAME: yourdockerhub/springboot-postgres
96-
IMAGE_TAG: ${{ needs.build-and-push.outputs.image-tag }}
90+
git push origin auto/kustomize-update --force
9791
9892
9993

0 commit comments

Comments
 (0)