Skip to content

Added kustomize

Added kustomize #12

name: Build Docker and push
on:
push:
branches:
- main
tags:
- '*'
pull_request:
env:
REGISTRY: ghcr.io
IMAGE: ${{ github.repository }}
TAG: ${{ format('main-{0}', github.event.pull_request.head.sha || github.sha) }}
jobs:
build_and_push_docker:
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set docker image env var
run: |
echo "DOCKER_IMAGE=${REGISTRY}/${IMAGE}:${TAG}" >> $GITHUB_ENV
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: 'Login to GitHub Container Registry'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Build with Gradle
run: ./gradlew clean bootJar jibDockerBuild --image=${{ env.DOCKER_IMAGE }} --build-cache --info
- name: Docker push
run: |
docker tag ${{env.DOCKER_IMAGE}} ${{env.REGISTRY}}/${{env.IMAGE}}:${{ env.TAG }}-gh${{ github.run_id }}
docker tag ${{env.DOCKER_IMAGE}} ${{env.REGISTRY}}/${{env.IMAGE}}:latest
docker push ${{env.REGISTRY}}/${{env.IMAGE}} --all-tags
retag_docker:
if: ${{ startsWith(github.ref, 'refs/tags/') }}
permissions:
contents: "read"
id-token: "write"
runs-on: ubuntu-latest
steps:
- name: Set docker image env var
run: |
echo "DOCKER_IMAGE=${REGISTRY}/${IMAGE}:${TAG}" >> $GITHUB_ENV
- name: 'Login to GitHub Container Registry'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
- name: Re-tag docker
run: |
docker pull ${{env.DOCKER_IMAGE}}
docker tag ${{env.DOCKER_IMAGE}} ${{env.REGISTRY}}/${{env.IMAGE}}:${{ github.ref_name }}
docker push ${{env.REGISTRY}}/${{env.IMAGE}} --all-tags