feat: Support graceful job step cancellation (#2714)

* feat: Support graceful job step cancellation

* for gh-act-runner
* act-cli support as well
* respecting always() and cancelled() of steps

* change main

* cancel startContainer / gh cli / bugreport early

* add to watch as well

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
ChristopherHX
2025-03-29 18:00:37 +01:00
committed by GitHub
parent 517c3ac467
commit bea04dd8f9
8 changed files with 241 additions and 28 deletions

24
main.go
View File

@@ -1,36 +1,18 @@
package main
import (
"context"
_ "embed"
"os"
"os/signal"
"syscall"
"github.com/nektos/act/cmd"
"github.com/nektos/act/pkg/common"
)
//go:embed VERSION
var version string
func main() {
ctx := context.Background()
ctx, cancel := context.WithCancel(ctx)
// trap Ctrl+C and call cancel on the context
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
defer func() {
signal.Stop(c)
cancel()
}()
go func() {
select {
case <-c:
cancel()
case <-ctx.Done():
}
}()
ctx, cancel := common.CreateGracefulJobCancellationContext()
defer cancel()
// run the command
cmd.Execute(ctx, version)