From 2211216b2ce55b2e35d1bd9bd0a58935de76a6a3 Mon Sep 17 00:00:00 2001 From: August Heiervang Dahl Date: Fri, 27 Sep 2024 14:18:45 +0200 Subject: [PATCH] =?UTF-8?q?Pr=C3=B8v=20ny=20m=C3=A5te=20=C3=A5=20dytte=20i?= =?UTF-8?q?nn=20bygg-argumenter=20i=20Docker-fila=20(#104)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Endelig har jeg fått injected miljøvariabler til Dockerfilen. Problemet lå i selve Dockerfilen, ikke modulen. Lager en ny versjon av modulen og tar den i bruk i datamarkedsplassen --- .github/workflows/publish-docker-image.yml | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-docker-image.yml b/.github/workflows/publish-docker-image.yml index 8af7c4b..77d3a17 100644 --- a/.github/workflows/publish-docker-image.yml +++ b/.github/workflows/publish-docker-image.yml @@ -18,7 +18,7 @@ on: default: "./versions" type: string env_vars: - description: "Optional environment variables to be injected at build time" + description: "Optional environment variables (JSON) to be injected at build time" required: false default: "" type: string @@ -69,6 +69,23 @@ jobs: username: ${{ github.actor }} password: ${{ github.token }} + - name: Prepare build arguments + id: prepare-build-args + run: | + BUILD_ARGS="" + echo '${{ inputs.env_vars }}' | jq -r 'to_entries | .[] | "\(.key)=\(.value)"' > build_args.txt + first=true + while IFS= read -r line; do + if [ "$first" = true ]; then + BUILD_ARGS="$line" + first=false + else + BUILD_ARGS="$BUILD_ARGS --build-arg $line" + fi + done < build_args.txt + # Save the build-args string in the environment + echo "BUILD_ARGS=$BUILD_ARGS" >> $GITHUB_ENV + - name: Build and push Docker image if: steps.check_changes.outputs.skip_build == 'false' id: build-docker @@ -78,7 +95,8 @@ jobs: context: ${{ env.CONTEXT_PATH }} push: ${{ !github.event.pull_request.draft }} tags: ${{ env.REGISTRY }}/${{ github.repository }}:latest - build-args: ${{ inputs.env_vars }} + build-args: | + ${{ env.BUILD_ARGS }} - name: Checkout the repository if: steps.check_changes.outputs.skip_build == 'false'