Skip to content

[app][ver] incr feat mark #49

[app][ver] incr feat mark

[app][ver] incr feat mark #49

Workflow file for this run

name: Docker
# run only, when version-tag pushed
on:
push:
tags:
- 'v*.*.*'
- '*.*.*'
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
docker_build_and_deploy:
runs-on: ubuntu-latest
# restrict to master only
if: ${{ github.event.ref }} == 'refs/heads/master'
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Check Tag
id: check_tag
run: |
if [[ ${{ github.event.ref }} =~ ^refs/tags/v?[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "It matches: ${{ github.event.ref }}"
echo "tag_matches=true" >> $GITHUB_OUTPUT
else
echo "It does not match: ${{ github.event.ref }}"
echo "tag_matches=false" >> $GITHUB_OUTPUT
fi
- name: Set up JDK 11-LTS
id: jdk
if: steps.check_tag.outputs.tag_matches == 'true'
uses: actions/setup-java@v1
with:
java-version: 11
- name: maven build
id: maven_build
if: steps.check_tag.outputs.tag_matches == 'true'
run: mvn clean package
# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
if: steps.check_tag.outputs.tag_matches == 'true'
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
- name: Docker meta
if: steps.check_tag.outputs.tag_matches == 'true'
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}.{{patch}}
- name: Log into registry ${{ env.REGISTRY }}
if: steps.check_tag.outputs.tag_matches == 'true'
id: login_ghcr_io
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
if: steps.check_tag.outputs.tag_matches == 'true'
id: build_docker
uses: docker/build-push-action@v4
with:
build-args: |
VERSION=${{ steps.meta.outputs.version }}
JAR_FILE_NAME=${{ github.event.repository.name }}-${{ steps.meta.outputs.version }}.jar
JAR_FILE=target/${{ github.event.repository.name }}-${{ steps.meta.outputs.version }}.jar
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}