Skip to content

Commit 6ecacfb

Browse files
committed
update ci yaml
1 parent bc7026f commit 6ecacfb

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

browser/browser.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ func New(opts Options) (*Browser, error) {
4646
if !opts.Headless {
4747
allocOpts = append(allocOpts, chromedp.Flag("headless", false))
4848
}
49+
if shouldDisableSandbox() {
50+
allocOpts = append(allocOpts,
51+
chromedp.Flag("no-sandbox", true),
52+
chromedp.Flag("disable-setuid-sandbox", true),
53+
)
54+
}
4955
if opts.Profile != "" {
5056
allocOpts = append(allocOpts, chromedp.UserDataDir(opts.Profile))
5157
}

browser/options.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package browser
22

3-
import "time"
3+
import (
4+
"os"
5+
"runtime"
6+
"time"
7+
)
48

59
type Options struct {
610
Headless bool
@@ -42,3 +46,16 @@ func (o Options) normalized() Options {
4246
}
4347
return o
4448
}
49+
50+
func shouldDisableSandbox() bool {
51+
if runtime.GOOS != "linux" {
52+
return false
53+
}
54+
if os.Getenv("KO_BROWSER_NO_SANDBOX") != "" {
55+
return true
56+
}
57+
if os.Getenv("GITHUB_ACTIONS") == "true" {
58+
return true
59+
}
60+
return os.Getenv("CI") != ""
61+
}

0 commit comments

Comments
 (0)