-
Notifications
You must be signed in to change notification settings - Fork 4
101 lines (84 loc) · 2.5 KB
/
container-dev.yml
File metadata and controls
101 lines (84 loc) · 2.5 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# Almost entirely written by ChatGPT
name: Build and publish dev container
on:
push:
branches:
- main
paths-ignore:
- '**.md'
- '.github/ISSUE_TEMPLATE/**'
- 'LICENSE'
- '.doc-misc/**'
workflow_dispatch:
permissions:
contents: read
packages: write
env:
IMAGE_NAME: fetcharr
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '21'
cache: maven
- name: Build project
run: mvn -B clean package
- name: Find main JAR
id: jar
shell: bash
run: |
set -Eeuo pipefail
shopt -s nullglob
candidates=()
for f in ./App/target/*.jar; do
name="$(basename "$f")"
case "$name" in
*-sources.jar|*-javadoc.jar|*-javadoc-resources.jar|*-test-javadoc-resources.jar|original-*.jar)
continue
;;
*)
candidates+=("$f")
;;
esac
done
if (( ${#candidates[@]} == 0 )); then
echo "No usable JAR found in ./App/target" >&2
exit 1
fi
jar_file="$(printf '%s\n' "${candidates[@]}" | awk -F/ '{print length($NF), $0}' | sort -n | head -n1 | cut -d' ' -f2-)"
echo "jar_file=$jar_file" >> "$GITHUB_OUTPUT"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push multi-arch dev image
uses: docker/build-push-action@v6
with:
context: .
file: ./Containerfile
push: true
platforms: linux/amd64,linux/arm64,linux/ppc64le
build-args: |
JAR_FILE=${{ steps.jar.outputs.jar_file }}
tags: |
docker.io/egg82/fetcharr:dev
ghcr.io/${{ github.repository_owner }}/fetcharr:dev
cache-from: type=gha
cache-to: type=gha,mode=max