Skip to content

add ability to control container image autorebuild #116

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

Merged
merged 1 commit into from
Jul 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions docs/actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ Action runtime options:
--entrypoint string Image Entrypoint: Overwrite the default ENTRYPOINT of the image. Example: --entrypoint "/bin/sh"
--exec Exec command: Overwrite the command of the action. Argument and options are not validated, sets container CMD directly. Example usage: --exec -- ls -lah
--no-cache No cache: Send command to build container without cache
--rebuild-image Rebuild image: Rebuild image if the action directory or the Dockerfile has changed
--remote-copy-back Remote copy back: Copies the working directory back from the container. Works only if the runtime is remote.
--remote-runtime Remote runtime: Forces the container runtime to be used as remote. Copies the working directory to a container volume. Local binds are not used.
--remove-image Remove Image: Remove an image after execution of action
Expand Down
27 changes: 20 additions & 7 deletions pkg/action/runtime.container.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ const (
containerActionMount = "/action"

// Environment specific flags.
containerFlagRemote = "remote-runtime"
containerFlagCopyBack = "remote-copy-back"
containerFlagRemoveImage = "remove-image"
containerFlagNoCache = "no-cache"
containerFlagEntrypoint = "entrypoint"
containerFlagExec = "exec"
containerFlagRemote = "remote-runtime"
containerFlagCopyBack = "remote-copy-back"
containerFlagRemoveImage = "remove-image"
containerFlagNoCache = "no-cache"
containerFlagRebuildImage = "rebuild-image"
containerFlagEntrypoint = "entrypoint"
containerFlagExec = "exec"
)

type runtimeContainer struct {
Expand All @@ -53,6 +54,7 @@ type runtimeContainer struct {
copyBack bool
removeImg bool
noCache bool
rebuildImage bool
entrypoint string
entrypointSet bool
exec bool
Expand Down Expand Up @@ -133,6 +135,13 @@ func (c *runtimeContainer) GetFlags() *FlagsGroup {
Type: jsonschema.Boolean,
Default: false,
},
&DefParameter{
Name: containerFlagRebuildImage,
Title: "Auto-rebuild image",
Description: "Rebuild image if the action directory or the Dockerfile has changed",
Type: jsonschema.Boolean,
Default: true,
},
&DefParameter{
Name: containerFlagEntrypoint,
Title: "Image Entrypoint",
Expand Down Expand Up @@ -190,6 +199,10 @@ func (c *runtimeContainer) SetFlags(input *Input) error {
c.noCache = nc.(bool)
}

if rb, ok := flags[containerFlagRebuildImage]; ok {
c.rebuildImage = rb.(bool)
}

if e, ok := flags[containerFlagEntrypoint]; ok && e != "" {
c.entrypointSet = true
c.entrypoint = e.(string)
Expand Down Expand Up @@ -392,7 +405,7 @@ func (c *runtimeContainer) imageRemove(ctx context.Context, a *Action) error {

func (c *runtimeContainer) isRebuildRequired(bi *driver.BuildDefinition) (bool, error) {
// @todo test image cache resolution somehow.
if c.imgccres == nil || bi == nil {
if c.imgccres == nil || bi == nil || !c.rebuildImage {
return false, nil
}

Expand Down