Merge pull request #104 from patbaumgartner/dependabot/maven/telegram… #274
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
# This workflow will build a Docker Container using Maven and then publish it to Dockerhub when change was made. | |
name: Maven Build and Publish Docker image | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Docker meta | |
id: meta | |
if: github.event_name != 'pull_request' | |
uses: docker/metadata-action@v5.6.1 | |
with: | |
images: patbaumgartner/lovebox-telegram-sender | |
tags: | | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
- name: Login to DockerHub | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push Docker images | |
if: github.event_name != 'pull_request' | |
uses: docker/build-push-action@v6.10.0 | |
with: | |
push: true | |
tags: patbaumgartner/builder-jammy-base:latest | |
file: Dockerfile.base-cnb | |
- name: Set up JDK | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '21' | |
distribution: 'temurin' | |
cache: maven | |
- name: Build with Maven | |
run: mvn clean verify --batch-mode --no-transfer-progress | |
- name: Build Docker Container with Maven and Publish to Docker Hub | |
if: github.event_name != 'pull_request' | |
run: | | |
mvn spring-boot:build-image \ | |
--batch-mode --no-transfer-progress \ | |
-Dspring-boot.build-image.imageName=${{ steps.meta.outputs.tags }} \ | |
-Dspring-boot.build-image.runImage=patbaumgartner/builder-jammy-base:latest \ | |
-Dspring-boot.build-image.publish=true \ | |
-DCI_REGISTRY=https://index.docker.io/v1/ \ | |
-DCI_REGISTRY_USER=${{ secrets.DOCKER_USERNAME }} \ | |
-DCI_REGISTRY_PASSWORD=${{ secrets.DOCKER_PASSWORD }} |