-
Notifications
You must be signed in to change notification settings - Fork 41
52 lines (50 loc) · 1.75 KB
/
build-image.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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}" .