mirror of
https://github.com/Luzifer/ots.git
synced 2024-12-18 03:54:38 -05:00
CI: Add multi-platform image build
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
496ace34f4
commit
73209fc52c
17
.github/workflows/docker-publish.yml
vendored
17
.github/workflows/docker-publish.yml
vendored
@ -18,6 +18,12 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
lfs: true
|
||||
@ -31,6 +37,15 @@ jobs:
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Docker Build & Publish
|
||||
run: bash ci/docker-publish.sh
|
||||
id: taggen
|
||||
run: bash ci/docker-gen-tagnames.sh
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: ${{ steps.taggen.outputs.docker_build_tags }}
|
||||
|
||||
...
|
||||
|
@ -5,7 +5,7 @@ function log() {
|
||||
echo "[$(date +%H:%M:%S)] $@" >&2
|
||||
}
|
||||
|
||||
[[ -n $GITHUB_REF_NAME ]] || {
|
||||
[[ -n ${GITHUB_REF_NAME:-} ]] || {
|
||||
log "ERR: This script is intended to run on a Github Action only."
|
||||
exit 1
|
||||
}
|
||||
@ -16,11 +16,11 @@ tags=()
|
||||
case "${GITHUB_REF_TYPE}" in
|
||||
branch)
|
||||
# Generic build to develop: Workflow has to limit branches to master
|
||||
tags+=(develop)
|
||||
tags+=("${repo}:develop")
|
||||
;;
|
||||
tag)
|
||||
# Build to latest & tag: Older tags are not intended to rebuild
|
||||
tags+=(latest ${GITHUB_REF_NAME})
|
||||
tags+=("${repo}:latest" "${repo}:${GITHUB_REF_NAME}")
|
||||
;;
|
||||
*)
|
||||
log "ERR: The ref type ${GITHUB_REF_TYPE} is not handled."
|
||||
@ -28,13 +28,5 @@ tag)
|
||||
;;
|
||||
esac
|
||||
|
||||
log "Building Docker image..."
|
||||
docker build -t "${repo}:local" .
|
||||
|
||||
for ref in "${tags[@]}"; do
|
||||
log "Pushing Docker image to '${repo}:${ref}'..."
|
||||
docker tag "${repo}:local" "${repo}:${ref}"
|
||||
docker push "${repo}:${ref}"
|
||||
done
|
||||
|
||||
log "Publish finished."
|
||||
export IFS=,
|
||||
echo "docker_build_tags=${tags[*]}" >>${GITHUB_OUTPUT}
|
Loading…
Reference in New Issue
Block a user