Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2
updates:
- package-ecosystem: "maven"
directory: "/springboot-postgres/app"
schedule:
interval: "daily"

- package-ecosystem: "docker"
directory: "/springboot-postgres/app"
schedule:
interval: "weekly"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
164 changes: 82 additions & 82 deletions .github/workflows/helm-ci.yaml
Original file line number Diff line number Diff line change
@@ -1,82 +1,82 @@
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
# 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
180 changes: 90 additions & 90 deletions .github/workflows/kustomize-ci.yaml
Original file line number Diff line number Diff line change
@@ -1,93 +1,93 @@
name: Kustomize CI - Build and Push

on:
push:
branches:
- feature/development
- development

concurrency:
group: kustomize-update
cancel-in-progress: true

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)
BRANCH=$(echo "${GITHUB_REF#refs/heads/}" | tr '/' '-')
TAG="${BRANCH}-${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-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: 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 and push to branch
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"

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 auto/kustomize-update --force
# name: Kustomize CI - Build and Push

# on:
# push:
# branches:
# - feature/development
# - development

# concurrency:
# group: kustomize-update
# cancel-in-progress: true

# 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)
# BRANCH=$(echo "${GITHUB_REF#refs/heads/}" | tr '/' '-')
# TAG="${BRANCH}-${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-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: 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 and push to branch
# 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"

# 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 auto/kustomize-update --force



Loading