Merge pull request #13 from wiemanboy/feature/fix-allow-public-data #20
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create Docker image and release | |
on: | |
push: | |
branches: | |
- master | |
- release/* | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version of the application' | |
required: false | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.set-version.outputs.version }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set version | |
id: set-version | |
run: echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV | |
- name: Install xmllint | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y libxml2-utils | |
- name: Extract version from pom.xml | |
if: github.event.inputs.version == '' | |
id: extract-version | |
run: | | |
VERSION=$(xmllint --xpath 'string(/*[local-name()="project"]/*[local-name()="version"])' pom.xml) | |
echo "VERSION=${VERSION}" >> $GITHUB_ENV | |
- name: Authorize in Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: | | |
${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_IMAGE_NAME }}:${{ env.VERSION }} | |
${{ github.ref == 'refs/heads/master' && format('{0}/{1}:latest', secrets.DOCKER_HUB_USERNAME, vars.DOCKER_IMAGE_NAME) || '' }} | |
- name: Create release | |
uses: marvinpinto/action-automatic-releases@latest | |
with: | |
repo_token: "${{ secrets.TOKEN }}" | |
automatic_release_tag: ${{ env.VERSION }} | |
prerelease: ${{ github.ref != 'refs/heads/master' }} | |
title: "${{ github.event.repository.name }} v${{ env.VERSION }}" |