Skip to content

Commit 8ad6c07

Browse files
Ryanmergify[bot]
Ryan
andauthored
feat: add option for docker image rebuild (#878)
Adds option to rebuild local action docker images Fixed up README due to missing flags after PR #714 and #716 Signed-off-by: hackercat <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent ff8b1df commit 8ad6c07

File tree

5 files changed

+10
-3
lines changed

5 files changed

+10
-3
lines changed

README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,12 @@ It will save that information to `~/.actrc`, please refer to [Configuration](#co
165165

166166
```none
167167
-a, --actor string user that triggered the event (default "nektos/act")
168-
--artifact-server-path string Defines the path where the artifact server stores uploads and retrieves downloads from.
169-
If not specified the artifact server will not start.
168+
--artifact-server-path string Defines the path where the artifact server stores uploads and retrieves downloads from. If not specified the artifact server will not start.
170169
--artifact-server-port string Defines the port where the artifact server listens (will only bind to localhost). (default "34567")
171170
-b, --bind bind working directory to container, rather than copy
172171
--container-architecture string Architecture which should be used to run containers, e.g.: linux/amd64. If not specified, will use host default architecture. Requires Docker server API Version 1.41+. Ignored on earlier Docker server platforms.
172+
--container-cap-add stringArray kernel capabilities to add to the workflow containers (e.g. --container-cap-add SYS_PTRACE)
173+
--container-cap-drop stringArray kernel capabilities to remove from the workflow containers (e.g. --container-cap-drop SYS_PTRACE)
173174
--container-daemon-socket string Path to Docker daemon socket which will be mounted to containers (default "/var/run/docker.sock")
174175
--defaultbranch string the name of the main branch
175176
--detect-event Use first event type from workflow as event that triggered the workflow
@@ -189,7 +190,9 @@ It will save that information to `~/.actrc`, please refer to [Configuration](#co
189190
--privileged use privileged mode
190191
-p, --pull pull docker image(s) even if already present
191192
-q, --quiet disable logging of output from steps
193+
--rebuild rebuild local action docker image(s) even if already present
192194
-r, --reuse reuse action containers to maintain state
195+
--rm automatically remove containers just before exit
193196
-s, --secret stringArray secret to make available to actions with optional value (e.g. -s mysecret=foo or -s mysecret)
194197
--secret-file string file with list of secrets to read from (e.g. --secret-file .secrets) (default ".secrets")
195198
--use-gitignore Controls whether paths specified in .gitignore should be copied into container (default true)

cmd/input.go

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ type Input struct {
2020
platforms []string
2121
dryrun bool
2222
forcePull bool
23+
forceRebuild bool
2324
noOutput bool
2425
envfile string
2526
secretfile string

cmd/root.go

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ func Execute(ctx context.Context, version string) {
4545
rootCmd.Flags().BoolVarP(&input.reuseContainers, "reuse", "r", false, "reuse action containers to maintain state")
4646
rootCmd.Flags().BoolVarP(&input.bindWorkdir, "bind", "b", false, "bind working directory to container, rather than copy")
4747
rootCmd.Flags().BoolVarP(&input.forcePull, "pull", "p", false, "pull docker image(s) even if already present")
48+
rootCmd.Flags().BoolVarP(&input.forceRebuild, "rebuild", "", false, "rebuild local action docker image(s) even if already present")
4849
rootCmd.Flags().BoolVarP(&input.autodetectEvent, "detect-event", "", false, "Use first event type from workflow as event that triggered the workflow")
4950
rootCmd.Flags().StringVarP(&input.eventPath, "eventpath", "e", "", "path to event JSON file")
5051
rootCmd.Flags().StringVar(&input.defaultBranch, "defaultbranch", "", "the name of the main branch")
@@ -260,6 +261,7 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str
260261
EventPath: input.EventPath(),
261262
DefaultBranch: defaultbranch,
262263
ForcePull: input.forcePull,
264+
ForceRebuild: input.forceRebuild,
263265
ReuseContainers: input.reuseContainers,
264266
Workdir: input.Workdir(),
265267
BindWorkdir: input.bindWorkdir,

pkg/runner/runner.go

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type Config struct {
2929
DefaultBranch string // name of the main branch for this repository
3030
ReuseContainers bool // reuse containers to maintain state
3131
ForcePull bool // force pulling of the image, even if already present
32+
ForceRebuild bool // force rebuilding local docker image action
3233
LogOutput bool // log the output from docker run
3334
Env map[string]string // env for containers
3435
Secrets map[string]string // list of secrets

pkg/runner/step_context.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ func (sc *StepContext) execAsDocker(ctx context.Context, action *model.Action, a
552552
}
553553
}
554554

555-
if !correctArchExists {
555+
if !correctArchExists || rc.Config.ForceRebuild {
556556
log.Debugf("image '%s' for architecture '%s' will be built from context '%s", image, rc.Config.ContainerArchitecture, contextDir)
557557
var actionContainer container.Container
558558
if localAction {

0 commit comments

Comments
 (0)