diff --git a/action.yml b/action.yml index 55b6cfc..b3f44b8 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: | + 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: ' ' 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..4e35767 --- /dev/null +++ b/build_opts_check.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Expected env vars: +# 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 is set to true.' + exit 1 + fi + + if grep -qE '(-s)|(--squash)' <<< "$BUILD_OPTS"; then + 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 add --push to build_opts, as the action already provides that argument.' + exit 1 +fi + +exit 0