Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow providing options to bluebuild build command #63

Merged
merged 4 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: |
Provides options to the call to the call to bluebuild build. If you use with
xynydev marked this conversation as resolved.
Show resolved Hide resolved
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.
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 @@
#!/bin/bash
dkolb marked this conversation as resolved.
Show resolved Hide resolved

# 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