docker_publish workflow #3
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
# CI with maven build and scan | |
name: CI docker build | |
on: | |
# Trigger analysis when pushing in master or pull requests, and when creating | |
# a pull request. | |
push: | |
branches: | |
- develop | |
release: | |
types: [published] | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# Shallow clones should be disabled for a better relevancy of analysis | |
fetch-depth: 0 | |
- name: Echo ref name trigger | |
run: echo ${{ github.ref_name }} | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '21' | |
distribution: 'corretto' | |
cache: 'maven' | |
- name: Cache Maven packages | |
uses: actions/cache@v4 | |
with: | |
path: ~/.m2 | |
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-m2 | |
- name: Cache SonarCloud packages | |
uses: actions/cache@v1 | |
with: | |
path: ~/.sonar/cache | |
key: ${{ runner.os }}-sonar | |
restore-keys: ${{ runner.os }}-sonar | |
- name: Maven version | |
run: mvn -v | |
env: | |
# Needed to get some information about the pull request, if any | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# SonarCloud access token should be generated from https://sonarcloud.io/account/security/ | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
- name: Build and analyze | |
run: mvn -B clean package | |
# using action https://github.com/marketplace/actions/build-and-push-docker-images | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: fugeritorg/fj-daogen-quickstart:${{ github.ref_name }},fugeritorg/fj-daogen-quickstart:latest |