forked from Ivasoft/github-actions
Allow KVM access on request
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -81,6 +81,11 @@ func main() {
|
|||||||
Usage: "disable forced pulling in act",
|
Usage: "disable forced pulling in act",
|
||||||
EnvVar: "PLUGIN_NO_FORCE_PULL",
|
EnvVar: "PLUGIN_NO_FORCE_PULL",
|
||||||
},
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "kvm",
|
||||||
|
Usage: "enable KVM (Kernel Virtual Machine)",
|
||||||
|
EnvVar: "PLUGIN_KVM",
|
||||||
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "event-payload",
|
Name: "event-payload",
|
||||||
Usage: "Webhook event payload",
|
Usage: "Webhook event payload",
|
||||||
@@ -194,6 +199,7 @@ func run(c *cli.Context) error {
|
|||||||
Verbose: c.Bool("action-verbose"),
|
Verbose: c.Bool("action-verbose"),
|
||||||
Image: c.String("action-image"),
|
Image: c.String("action-image"),
|
||||||
NoForcePull: c.Bool("no-force-pull"),
|
NoForcePull: c.Bool("no-force-pull"),
|
||||||
|
Kvm: c.Bool("kvm"),
|
||||||
EventPayload: c.String("event-payload"),
|
EventPayload: c.String("event-payload"),
|
||||||
Actor: c.String("actor"),
|
Actor: c.String("actor"),
|
||||||
},
|
},
|
||||||
|
|||||||
10
plugin.go
10
plugin.go
@@ -39,6 +39,7 @@ type (
|
|||||||
Actor string
|
Actor string
|
||||||
Verbose bool
|
Verbose bool
|
||||||
NoForcePull bool
|
NoForcePull bool
|
||||||
|
Kvm bool
|
||||||
}
|
}
|
||||||
|
|
||||||
Plugin struct {
|
Plugin struct {
|
||||||
@@ -94,7 +95,11 @@ func (p Plugin) Exec() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if p.Action.NoForcePull {
|
if p.Action.NoForcePull {
|
||||||
cmdArgs = append(cmdArgs, "-p=false")
|
cmdArgs = append(cmdArgs, "--pull=false")
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.Action.Kvm {
|
||||||
|
cmdArgs = append(cmdArgs, "--privileged")
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.Daemon.Disabled {
|
if p.Daemon.Disabled {
|
||||||
@@ -111,6 +116,9 @@ func (p Plugin) Exec() error {
|
|||||||
bindModifiers = ":z"
|
bindModifiers = ":z"
|
||||||
}
|
}
|
||||||
cmdArgs = append(cmdArgs, "--container-options", fmt.Sprintf("--volume=%s:%s%s", hostWorkDirPath, guestWorkDirPath, bindModifiers))
|
cmdArgs = append(cmdArgs, "--container-options", fmt.Sprintf("--volume=%s:%s%s", hostWorkDirPath, guestWorkDirPath, bindModifiers))
|
||||||
|
if p.Action.Kvm {
|
||||||
|
cmdArgs = append(cmdArgs, "--volume=/dev/kvm:/dev/kvm")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := exec.Command("act", cmdArgs...)
|
cmd := exec.Command("act", cmdArgs...)
|
||||||
|
|||||||
Reference in New Issue
Block a user