Skip to content

Commit f09cdb8

Browse files
feat: add flag to always run the checkout action (#1049)
act has a feature that skips the checkout action to do a remote checkout when a local checkout exists. in some cases, e.g. when running act in a CI, you always want to clone the repository.
1 parent 4d71071 commit f09cdb8

File tree

5 files changed

+9
-1
lines changed

5 files changed

+9
-1
lines changed

cmd/input.go

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ type Input struct {
3939
artifactServerPath string
4040
artifactServerPort string
4141
jsonLogger bool
42+
noSkipCheckout bool
4243
}
4344

4445
func (i *Input) resolve(path string) string {

cmd/root.go

+2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ func Execute(ctx context.Context, version string) {
7171
rootCmd.PersistentFlags().StringVarP(&input.githubInstance, "github-instance", "", "github.com", "GitHub instance to use. Don't use this if you are not using GitHub Enterprise Server.")
7272
rootCmd.PersistentFlags().StringVarP(&input.artifactServerPath, "artifact-server-path", "", "", "Defines the path where the artifact server stores uploads and retrieves downloads from. If not specified the artifact server will not start.")
7373
rootCmd.PersistentFlags().StringVarP(&input.artifactServerPort, "artifact-server-port", "", "34567", "Defines the port where the artifact server listens (will only bind to localhost).")
74+
rootCmd.PersistentFlags().BoolVarP(&input.noSkipCheckout, "no-skip-checkout", "", false, "Do not skip actions/checkout")
7475
rootCmd.SetArgs(args())
7576

7677
if err := rootCmd.Execute(); err != nil {
@@ -287,6 +288,7 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str
287288
AutoRemove: input.autoRemove,
288289
ArtifactServerPath: input.artifactServerPath,
289290
ArtifactServerPort: input.artifactServerPort,
291+
NoSkipCheckout: input.noSkipCheckout,
290292
}
291293
r, err := runner.New(config)
292294
if err != nil {

pkg/runner/run_context.go

+4
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,10 @@ func setActionRuntimeVars(rc *RunContext, env map[string]string) {
708708
}
709709

710710
func (rc *RunContext) localCheckoutPath() (string, bool) {
711+
if rc.Config.NoSkipCheckout {
712+
return "", false
713+
}
714+
711715
ghContext := rc.getGithubContext()
712716
for _, step := range rc.Run.Job().Steps {
713717
if isLocalCheckout(ghContext, step) {

pkg/runner/runner.go

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ type Config struct {
4848
ArtifactServerPath string // the path where the artifact server stores uploads
4949
ArtifactServerPort string // the port the artifact server binds to
5050
CompositeRestrictions *model.CompositeRestrictions // describes which features are available in composite actions
51+
NoSkipCheckout bool // do not skip actions/checkout
5152
}
5253

5354
// Resolves the equivalent host path inside the container

pkg/runner/step_context.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func (sc *StepContext) Executor(ctx context.Context) common.Executor {
9292
remoteAction.URL = rc.Config.GitHubInstance
9393

9494
github := rc.getGithubContext()
95-
if remoteAction.IsCheckout() && isLocalCheckout(github, step) {
95+
if remoteAction.IsCheckout() && isLocalCheckout(github, step) && !rc.Config.NoSkipCheckout {
9696
return func(ctx context.Context) error {
9797
common.Logger(ctx).Debugf("Skipping local actions/checkout because workdir was already copied")
9898
return nil

0 commit comments

Comments
 (0)