Skip to content

Commit

Permalink
feat: allow providing options to bluebuild build command (#63)
Browse files Browse the repository at this point in the history
* feat: allow providing options to `bluebuild build` command

* chore: wording changes

* chore: wording changes, typo fix

* fix: proper shebang, stricter script options

---------

Co-authored-by: xyny <[email protected]>
  • Loading branch information
dkolb and xynydev authored Nov 11, 2024
1 parent b032506 commit acae198
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
18 changes: 15 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
25 changes: 25 additions & 0 deletions build_opts_check.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit acae198

Please sign in to comment.