summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorTom Lazar <me@tomlazar.science>2020-09-02 16:56:44 +0200
committerGitHub <noreply@github.com>2020-09-02 16:56:44 +0200
commit7d443c65202c3ac863b7c40425b2362cd2c83e2d (patch)
tree77afabad5fc7ffae2bd77c54df6ead9320bd0f3d /cmd
parentfeat: add fromJSON support (#352) (diff)
downloadforgejo-act-7d443c65202c3ac863b7c40425b2362cd2c83e2d.tar.xz
forgejo-act-7d443c65202c3ac863b7c40425b2362cd2c83e2d.zip
Set the default branch inside the event data (#354)v0.2.14
* set ${{github.event.repository.default_branch}} * change `ok == false` to `!ok` Co-authored-by: Casey Lee <cplee@nektos.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/input.go1
-rw-r--r--cmd/root.go8
2 files changed, 9 insertions, 0 deletions
diff --git a/cmd/input.go b/cmd/input.go
index 736c11b..8f817f3 100644
--- a/cmd/input.go
+++ b/cmd/input.go
@@ -20,6 +20,7 @@ type Input struct {
noOutput bool
envfile string
secretfile string
+ defaultBranch string
privileged bool
}
diff --git a/cmd/root.go b/cmd/root.go
index 8ac8d63..2e0b79a 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -41,6 +41,7 @@ func Execute(ctx context.Context, version string) {
rootCmd.Flags().BoolVarP(&input.bindWorkdir, "bind", "b", false, "bind working directory to container, rather than copy")
rootCmd.Flags().BoolVarP(&input.forcePull, "pull", "p", false, "pull docker image(s) if already present")
rootCmd.Flags().StringVarP(&input.eventPath, "eventpath", "e", "", "path to event JSON file")
+ rootCmd.Flags().StringVar(&input.defaultBranch, "defaultbranch", "", "the name of the main branch")
rootCmd.Flags().BoolVar(&input.privileged, "privileged", false, "use privileged mode")
rootCmd.PersistentFlags().StringVarP(&input.actor, "actor", "a", "nektos/act", "user that triggered the event")
rootCmd.PersistentFlags().StringVarP(&input.workflowsPath, "workflows", "W", "./.github/workflows/", "path to workflow file(s)")
@@ -156,11 +157,18 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str
return drawGraph(plan)
}
+ // check to see if the main branch was defined
+ defaultbranch, err := cmd.Flags().GetString("defaultbranch")
+ if err != nil {
+ return err
+ }
+
// run the plan
config := &runner.Config{
Actor: input.actor,
EventName: eventName,
EventPath: input.EventPath(),
+ DefaultBranch: defaultbranch,
ForcePull: input.forcePull,
ReuseContainers: input.reuseContainers,
Workdir: input.Workdir(),