Skip to content

Build Docker image

Build Docker image #60

Workflow file for this run

name: Build Docker image
on:
push:
branches:
- "master"
tags:
- "v*"
paths-ignore:
- '*.md'
pull_request:
branches:
- "master"
paths-ignore:
- '*.md'
env:
JAVA_VERSION: "17"
IMAGE_NAME: "ghcr.io/${{ github.repository }}"
jobs:
docker:
name: Push to GitHub Container Registry
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: "Login to ghcr.io"
uses: "docker/login-action@v1"
with:
registry: ghcr.io
username: "${{ github.repository_owner }}"
password: "${{ secrets.GITHUB_TOKEN }}"
- name: Checkout
uses: "actions/checkout@v2"
- name: Set up JDK
uses: "actions/setup-java@v3"
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: "temurin"
cache: "gradle"
- name: Docker meta
id: meta
uses: crazy-max/ghaction-docker-meta@v4
with:
images: "${{ env.IMAGE_NAME }}"
sep-tags: ","
sep-labels: ","
flavor: |
latest=auto
tags: |
type=ref,event=branch
type=ref,event=pr
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=edge,branch=master
type=sha
type=sha,format=long
# Hotfix for https://github.com/docker/metadata-action/issues/212
- name: Remove prefix from tags
id: meta_hotfix
run: echo "fixed_tags=${{ steps.meta.outputs.tags }}" | sed 's;${{ env.IMAGE_NAME }}:;;g' >> $GITHUB_ENV
- name: Build and Publish Docker Image
run: |
gradle jib \
-Djib.to.tags="${{ env.fixed_tags }}" \
-Djib.container.labels="${{ steps.meta.outputs.labels }}" \
-Djib.console=plain \
--image="ghcr.io/${{ github.repository }}"