Skip to content

Docker image deployment #4

Docker image deployment

Docker image deployment #4

name: Build (temp for testing)
on:
push:
branches-ignore:
- master
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Install Graphviz
run: sudo apt-get -y install graphviz
- name: Build with Maven
run: mvn -B package --file pom.xml
- uses: actions/cache@v2
id: target-cache
with:
path: ./target/*
key: ${{ github.sha }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
build_and_publish_docker_image:
name: Build and Publish Docker Image
runs-on: ubuntu-latest
needs: [ build ]
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v2
id: target-cache
with:
path: ./target/*
key: ${{ github.sha }}
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and Push (latest)
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
uses: docker/build-push-action@v5
with:
context: .
file: ./src/main/resources/Dockerfile
push: true
tags: contextmapper/ddd-cm-tla-sample-application:latest
- name: Build and Push (latest)
if: github.event_name == 'release'
uses: docker/build-push-action@v5
with:
context: .
file: ./src/main/resources/Dockerfile
push: true
tags: contextmapper/ddd-cm-tla-sample-application:${{ github.event.release.tag_name }}