refactoring #188
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: Publish Docker latest image | |
on: | |
push: | |
branches: | |
- 'master' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the code | |
uses: actions/checkout@v4 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '21' | |
distribution: 'adopt' | |
- name: Cache local Maven repository | |
uses: actions/cache@v4 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
- name: Build with Maven | |
run: mvn -B verify | |
- name: Extract jar for layered image building | |
run: java -Djarmode=layertools -jar target/fredbet.jar extract | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: app-binary | |
path: | | |
dependencies/ | |
spring-boot-loader/ | |
snapshot-dependencies/ | |
application/ | |
retention-days: 5 | |
build_push_buildx: | |
runs-on: ubuntu-latest | |
needs: build | |
env: | |
DOCKER_IMAGE: fred4jupiter/fredbet | |
DOCKER_TARGET_PLATFORM: linux/arm64/v8,linux/amd64 | |
steps: | |
- name: Checkout the code | |
uses: actions/checkout@v4 | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: app-binary | |
- name: Create missing directories | |
run: mkdir -p snapshot-dependencies | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
registry: docker.io | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push image | |
run: | | |
docker buildx build \ | |
--platform ${DOCKER_TARGET_PLATFORM} \ | |
--tag docker.io/${DOCKER_IMAGE}:latest \ | |
--tag ghcr.io/${DOCKER_IMAGE}:latest \ | |
--file ./Dockerfile \ | |
--output type=image,push=true . |