From bd09e1ee4f614a85e76c91afd3b5a78731d69f8e Mon Sep 17 00:00:00 2001 From: Aaron Reisman Date: Tue, 22 Oct 2024 03:45:44 -0500 Subject: [PATCH] Build both platforms in one action --- .github/workflows/docker.yml | 15 +++------------ Docker/liberate.sh | 15 ++++++++++----- Dockerfile | 4 ++-- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index d5ebf516..dd41c9f1 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -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 @@ -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 }} @@ -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 }} diff --git a/Docker/liberate.sh b/Docker/liberate.sh index 40ef534a..d44f1679 100755 --- a/Docker/liberate.sh +++ b/Docker/liberate.sh @@ -49,7 +49,12 @@ update_settings() { is_mounted() { DIR=$1 - return $(mount | grep ${DIR}) + if grep -q "${DIR}"; + then + return 0 + else + return 1 + fi } create_db() { @@ -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 @@ -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 @@ -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 diff --git a/Dockerfile b/Dockerfile index bf33ef79..88909c4e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 \