From 1acee344b45b5ef101ddd93f491ef1806213d0a7 Mon Sep 17 00:00:00 2001 From: David Kolb Date: Sat, 9 Nov 2024 14:53:18 -0500 Subject: [PATCH 1/4] feat: allow providing options to `bluebuild build` command --- action.yml | 18 +++++++++++++++--- build_opts_check.sh | 25 +++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 3 deletions(-) create mode 100755 build_opts_check.sh diff --git a/action.yml b/action.yml index 55b6cfc..f3e27a5 100644 --- a/action.yml +++ b/action.yml @@ -69,9 +69,16 @@ inputs: squash: description: | Uses buildah to squash the build's layers into a single layer. Use of this option - disables cache. + disables cache. Conflicts with adding --build-driver or --squash to the build opts. required: false default: 'false' + build_opts: + description: | + Provides options to the call to the call to bluebuild build. If you use with + the squash input set to true and provide a --build-driver or --squash option + an error will occur and the action will not run. + required: false + default: ' ' working_directory: description: | Changes working directory for whole build. @@ -89,6 +96,12 @@ inputs: runs: using: "composite" steps: + - name: Validate inputs + shell: bash + run: "${{ github.action_path }}/build_opts_check.sh" + env: + SQUASH_INPUT_VALUE: "${{ inputs.squash }}" + BUILD_OPTS: "${{ inputs.build_opts }}" # building custom images might take a lot of space, # so it's best to remove unneeded softawre - name: Maximize build space @@ -189,9 +202,8 @@ runs: RECIPE_PATH: ${{ steps.build_vars.outputs.recipe_path }} RUST_LOG_STYLE: always CLICOLOR_FORCE: '1' + BUILD_OPTS: ${{ inputs.build_opts }} run: | - BUILD_OPTS="" - if [ "${{ inputs.squash }}" = "true" ]; then BUILD_OPTS="--build-driver podman --squash $BUILD_OPTS" fi diff --git a/build_opts_check.sh b/build_opts_check.sh new file mode 100755 index 0000000..d33b3d0 --- /dev/null +++ b/build_opts_check.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Expected env vars: +# SQUASH_INPUT_VALUER +# BUILD_OPTS + +if [ "$SQUASH_INPUT_VALUE" != "true" ]; then + if grep -qE '(-B)|(--build-driver)' <<< "$BUILD_OPTS"; then + echo 'Cannot provide --build-driver in build_opts while squash = true' + exit 1 + fi + + if grep -qE '(-s)|(--squash)' <<< "$BUILD_OPTS"; then + echo 'Cannot provide --squash in build_opts while squash = true' + exit 1 + fi +fi + +if grep -qE '(-p)|(--push)' <<< "$BUILD_OPTS"; then + echo 'Please do not provide --push in build_opts as the action provides it' \ + ' by default anyway.' + exit 1 +fi + +exit 0 \ No newline at end of file From c4850af9774c7d289fca7f2ae08497806b238dbf Mon Sep 17 00:00:00 2001 From: xyny <60004820+xynydev@users.noreply.github.com> Date: Sun, 10 Nov 2024 16:04:11 +0000 Subject: [PATCH 2/4] chore: wording changes --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index f3e27a5..b3f44b8 100644 --- a/action.yml +++ b/action.yml @@ -74,8 +74,8 @@ inputs: default: 'false' build_opts: description: | - Provides options to the call to the call to bluebuild build. If you use with - the squash input set to true and provide a --build-driver or --squash option + Provide options to the call to the BlueBuild CLI build command. If you use this with + the squash input set to true and provide either of the --build-driver or --squash flags an error will occur and the action will not run. required: false default: ' ' From 760a29332374848dfb42e89ecb16a8354ea23573 Mon Sep 17 00:00:00 2001 From: xyny <60004820+xynydev@users.noreply.github.com> Date: Sun, 10 Nov 2024 16:07:21 +0000 Subject: [PATCH 3/4] chore: wording changes, typo fix --- build_opts_check.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/build_opts_check.sh b/build_opts_check.sh index d33b3d0..fbb275c 100755 --- a/build_opts_check.sh +++ b/build_opts_check.sh @@ -1,25 +1,24 @@ #!/bin/bash # Expected env vars: -# SQUASH_INPUT_VALUER +# SQUASH_INPUT_VALUE # BUILD_OPTS if [ "$SQUASH_INPUT_VALUE" != "true" ]; then if grep -qE '(-B)|(--build-driver)' <<< "$BUILD_OPTS"; then - echo 'Cannot provide --build-driver in build_opts while squash = true' + echo 'Cannot provide --build-driver in build_opts while squash is set to true.' exit 1 fi if grep -qE '(-s)|(--squash)' <<< "$BUILD_OPTS"; then - echo 'Cannot provide --squash in build_opts while squash = true' + echo 'Cannot provide --squash in build_opts while squash is set to true.' exit 1 fi fi if grep -qE '(-p)|(--push)' <<< "$BUILD_OPTS"; then - echo 'Please do not provide --push in build_opts as the action provides it' \ - ' by default anyway.' + echo 'Please do not add --push to build_opts, as the action already provides that argument.' exit 1 fi -exit 0 \ No newline at end of file +exit 0 From 0f46d2685f39ee60184a00e117ad608feccf1679 Mon Sep 17 00:00:00 2001 From: David Kolb Date: Sun, 10 Nov 2024 14:10:05 -0500 Subject: [PATCH 4/4] fix: proper shebang, stricter script options --- build_opts_check.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build_opts_check.sh b/build_opts_check.sh index fbb275c..4e35767 100755 --- a/build_opts_check.sh +++ b/build_opts_check.sh @@ -1,4 +1,5 @@ -#!/bin/bash +#!/usr/bin/env bash +set -euo pipefail # Expected env vars: # SQUASH_INPUT_VALUE