Skip to content

Build image

Build image #3

Workflow file for this run

name: Build image
on:
workflow_dispatch:
inputs:
docker_image_tag_name:
type: string
description: Docker image tag name (Optional)
jobs:
build-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: 11
distribution: 'adopt'
cache: 'maven'
- name: Build
run: |
./mvnw clean install -B -DskipTests -P exec-jar
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Prepare tag name
id: prepare_tag
run: |
if [ -n "${{ github.event.inputs.docker_image_tag_name }}" ]; then
tag_name=${{ github.event.inputs.docker_image_tag_name }}
else
tag_name=$(echo ${{ github.ref_name }} | sed 's/[^a-zA-Z0-9]/-/g')-$(git log -1 --pretty=%h)
fi
echo ::set-output name=tag_name::$tag_name
- name: Build Docker image
run: |
ACCIO_VERSION=$(./mvnw --quiet help:evaluate -Dexpression=project.version -DforceStdout)
cd ./docker
cp ../accio-server/target/accio-server-${ACCIO_VERSION}-executable.jar ./
docker buildx build \
--platform linux/amd64,linux/arm64 \
--tag ghcr.io/canner/accio:${{ steps.prepare_tag.outputs.tag_name }} \
--push -f ./Dockerfile \
--build-arg "ACCIO_VERSION=${ACCIO_VERSION}" .