From fb3853c72d8f6046d5b250da0f850df433b1ed47 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Thu, 16 Mar 2023 12:50:06 +0100 Subject: [PATCH] change in builder --- .albatros | 6 +++++- hcl/builder.hcl | 8 +++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.albatros b/.albatros index 8a82736..05d8951 100755 --- a/.albatros +++ b/.albatros @@ -1,3 +1,7 @@ #!/usr/bin/env bash nix build -nix develop --command "executor --force --destination dxflrs/albatros:${COMMIT} --context dir://`pwd` --verbosity=debug" +if [[ $BRANCH == "main" && -f $SECRET_PATH ]]; then + mkdir -p /kaniko/.docker ; cp $SECRET_PATH /kaniko/docker/.config.json + export HOME=/kaniko + nix develop --command sh -c "executor --force --destination dxflrs/albatros:${COMMIT} --context dir://`pwd` --verbosity=debug" +fi diff --git a/hcl/builder.hcl b/hcl/builder.hcl index 4c9f94d..3f0ed20 100644 --- a/hcl/builder.hcl +++ b/hcl/builder.hcl @@ -23,12 +23,12 @@ job "builder" { volumes = [ "local/builder.sh:/tmp/builder.sh", "local/nix.conf:/etc/nix/nix.conf", - "local/secret.txt:/var/run/secrets/albatros/secret.txt", + "local/secrets:/var/run/secrets/albatros", ] } dispatch_payload { - file = "secret.txt" + file = "secrets/secret.txt" } template { @@ -46,7 +46,9 @@ export COMMIT=${NOMAD_META_COMMIT} export BRANCH=${NOMAD_META_BRANCH} export REPO_URL=${NOMAD_META_REPO_URL} export FLAVOR=${NOMAD_META_FLAVOR} -export SECRET_PATH=/var/run/secrets/albatros/secret.txt +if [[ -f /var/run/secrets/albatros/secret.txt ]]; then + export SECRET_PATH=/var/run/secrets/albatros/secret.txt +fi ./.albatros EOH