Skip to content

Commit

Permalink
Build both platforms in one action
Browse files Browse the repository at this point in the history
  • Loading branch information
pixil98 authored and Aaron Reisman committed Oct 22, 2024
1 parent 011efe3 commit 9e69b4a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
15 changes: 3 additions & 12 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,7 @@ on:
jobs:
build_and_push:
runs-on: ubuntu-latest
strategy:
# Prevent a failure in one image from stopping the other builds
fail-fast: false
matrix:
os:
- ubuntu-latest
arch:
- amd64
- arm64

steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -43,6 +35,7 @@ jobs:
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
if: ${{ inputs.release }}
uses: docker/login-action@v3
with:
username: ${{ secrets.docker_username }}
Expand All @@ -62,11 +55,9 @@ jobs:
- name: Build and push image
uses: docker/build-push-action@v6
with:
platforms: ${{ matrix.arch }}
platforms: linux/amd64,linux/arm64
push: ${{ steps.metadata.outputs.tags != ''}}
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
build-args: |
TARGETARCH=${{ matrix.arch }}
15 changes: 10 additions & 5 deletions Docker/liberate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ update_settings() {

is_mounted() {
DIR=$1
return $(mount | grep ${DIR})
if mount | grep -q "${DIR}";
then
return 0
else
return 1
fi
}

create_db() {
Expand Down Expand Up @@ -93,9 +98,9 @@ main() {
info "loading database"
FILE=LibationContext.db
# If user provides a separate database mount, use that
if [ is_mounted ${LIBATION_DB_DIR} ];
if is_mounted ${LIBATION_DB_DIR};
then
debug using database directory `${LIBATION_DB_DIR}`
debug "using database directory ${LIBATION_DB_DIR}"
if [ -f "${LIBATION_DB_DIR}/${FILE}" ]; then
info "database found in ${LIBATION_DB_DIR}"
else
Expand All @@ -104,7 +109,7 @@ main() {
ln -s /${LIBATION_DB_DIR}/${FILE} ${LIBATION_CONFIG_INTERNAL}/${FILE}
# Otherwise, use the config directory
else
debug using config directory `${LIBATION_CONFIG_DIR}`
debug "using config directory ${LIBATION_CONFIG_DIR}"
if [ -f "${LIBATION_CONFIG_DIR}/${FILE}" ]; then
info "database found in ${LIBATION_CONFIG_DIR}"
else
Expand All @@ -114,7 +119,7 @@ main() {
fi

# Try to warn if books dir wasn't mounted in
if [ ! is_mounted ${LIBATION_BOOKS_DIR} ];
if !is_mounted ${LIBATION_BOOKS_DIR};
then
warn "${LIBATION_BOOKS_DIR} does not appear to be mounted, books will not be saved"
fi
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Dockerfile
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG TARGETARCH=amd64
FROM --platform=${BUILDPLATFORM} mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG TARGETARCH

COPY Source /Source
RUN dotnet publish \
Expand Down

0 comments on commit 9e69b4a

Please sign in to comment.