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.
This commit is contained in:
parent
4d7107161e
commit
f09cdb8443
5 changed files with 9 additions and 1 deletions
|
@ -39,6 +39,7 @@ type Input struct {
|
||||||
artifactServerPath string
|
artifactServerPath string
|
||||||
artifactServerPort string
|
artifactServerPort string
|
||||||
jsonLogger bool
|
jsonLogger bool
|
||||||
|
noSkipCheckout bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Input) resolve(path string) string {
|
func (i *Input) resolve(path string) string {
|
||||||
|
|
|
@ -71,6 +71,7 @@ func Execute(ctx context.Context, version string) {
|
||||||
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.")
|
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.")
|
||||||
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.")
|
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.")
|
||||||
rootCmd.PersistentFlags().StringVarP(&input.artifactServerPort, "artifact-server-port", "", "34567", "Defines the port where the artifact server listens (will only bind to localhost).")
|
rootCmd.PersistentFlags().StringVarP(&input.artifactServerPort, "artifact-server-port", "", "34567", "Defines the port where the artifact server listens (will only bind to localhost).")
|
||||||
|
rootCmd.PersistentFlags().BoolVarP(&input.noSkipCheckout, "no-skip-checkout", "", false, "Do not skip actions/checkout")
|
||||||
rootCmd.SetArgs(args())
|
rootCmd.SetArgs(args())
|
||||||
|
|
||||||
if err := rootCmd.Execute(); err != nil {
|
if err := rootCmd.Execute(); err != nil {
|
||||||
|
@ -287,6 +288,7 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str
|
||||||
AutoRemove: input.autoRemove,
|
AutoRemove: input.autoRemove,
|
||||||
ArtifactServerPath: input.artifactServerPath,
|
ArtifactServerPath: input.artifactServerPath,
|
||||||
ArtifactServerPort: input.artifactServerPort,
|
ArtifactServerPort: input.artifactServerPort,
|
||||||
|
NoSkipCheckout: input.noSkipCheckout,
|
||||||
}
|
}
|
||||||
r, err := runner.New(config)
|
r, err := runner.New(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -708,6 +708,10 @@ func setActionRuntimeVars(rc *RunContext, env map[string]string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rc *RunContext) localCheckoutPath() (string, bool) {
|
func (rc *RunContext) localCheckoutPath() (string, bool) {
|
||||||
|
if rc.Config.NoSkipCheckout {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
ghContext := rc.getGithubContext()
|
ghContext := rc.getGithubContext()
|
||||||
for _, step := range rc.Run.Job().Steps {
|
for _, step := range rc.Run.Job().Steps {
|
||||||
if isLocalCheckout(ghContext, step) {
|
if isLocalCheckout(ghContext, step) {
|
||||||
|
|
|
@ -48,6 +48,7 @@ type Config struct {
|
||||||
ArtifactServerPath string // the path where the artifact server stores uploads
|
ArtifactServerPath string // the path where the artifact server stores uploads
|
||||||
ArtifactServerPort string // the port the artifact server binds to
|
ArtifactServerPort string // the port the artifact server binds to
|
||||||
CompositeRestrictions *model.CompositeRestrictions // describes which features are available in composite actions
|
CompositeRestrictions *model.CompositeRestrictions // describes which features are available in composite actions
|
||||||
|
NoSkipCheckout bool // do not skip actions/checkout
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolves the equivalent host path inside the container
|
// Resolves the equivalent host path inside the container
|
||||||
|
|
|
@ -92,7 +92,7 @@ func (sc *StepContext) Executor(ctx context.Context) common.Executor {
|
||||||
remoteAction.URL = rc.Config.GitHubInstance
|
remoteAction.URL = rc.Config.GitHubInstance
|
||||||
|
|
||||||
github := rc.getGithubContext()
|
github := rc.getGithubContext()
|
||||||
if remoteAction.IsCheckout() && isLocalCheckout(github, step) {
|
if remoteAction.IsCheckout() && isLocalCheckout(github, step) && !rc.Config.NoSkipCheckout {
|
||||||
return func(ctx context.Context) error {
|
return func(ctx context.Context) error {
|
||||||
common.Logger(ctx).Debugf("Skipping local actions/checkout because workdir was already copied")
|
common.Logger(ctx).Debugf("Skipping local actions/checkout because workdir was already copied")
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in a new issue