Skip to content

Commit

Permalink
ci: embed build & push script in workflow (#154)
Browse files Browse the repository at this point in the history
This is to make it possible to build previous versions via the
workflow_dispatch event.
  • Loading branch information
williamboman authored Mar 19, 2023
1 parent 10b9324 commit 7844cb5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 33 deletions.
30 changes: 29 additions & 1 deletion .github/workflows/docker-image-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,32 @@ jobs:
- name: Build Docker image
env:
PLATFORMS: linux/amd64,linux/arm64/v8,linux/arm/v7
run: ./scripts/build-and-push.sh
run: |
set -euo pipefail
VERSION="$(git describe --exact-match --tags HEAD)"
TAG="$VERSION"
MAJOR_TAG="$(sed -nre 's/^([0-9]+).*/\1/p' <<< "$VERSION")"
DOCKERHUB_IMAGE="thelounge/thelounge"
GITHUB_IMAGE="ghcr.io/thelounge/thelounge"
TAGS=(
"--tag" "${DOCKERHUB_IMAGE}:${TAG}"
"--tag" "${GITHUB_IMAGE}:${TAG}"
)
# If not a pre-release push :latest & MAJOR_TAG
if grep -qE "^[0-9]*\.[0-9]*\.[0-9]*$" <<< "${VERSION}"; then
TAGS+=(
"--tag" "${DOCKERHUB_IMAGE}:latest"
"--tag" "${DOCKERHUB_IMAGE}:${MAJOR_TAG}"
"--tag" "${GITHUB_IMAGE}:latest"
"--tag" "${GITHUB_IMAGE}:${MAJOR_TAG}"
)
fi
docker buildx build \
--push \
--platform "${PLATFORMS}" \
"${TAGS[@]}" \
--file Dockerfile \
.
32 changes: 0 additions & 32 deletions scripts/build-and-push.sh

This file was deleted.

0 comments on commit 7844cb5

Please sign in to comment.