Skip to content

Commit 5a79256

Browse files
fix: panic (#2071)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 1bb2ee7 commit 5a79256

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

pkg/container/docker_run.go

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,22 @@ import (
1616
"strconv"
1717
"strings"
1818

19-
"github.com/go-git/go-billy/v5/helper/polyfill"
20-
"github.com/go-git/go-billy/v5/osfs"
21-
"github.com/go-git/go-git/v5/plumbing/format/gitignore"
22-
"github.com/joho/godotenv"
23-
24-
"github.com/imdario/mergo"
25-
"github.com/kballard/go-shellquote"
26-
"github.com/spf13/pflag"
27-
19+
"github.com/Masterminds/semver"
2820
"github.com/docker/cli/cli/connhelper"
2921
"github.com/docker/docker/api/types"
3022
"github.com/docker/docker/api/types/container"
3123
"github.com/docker/docker/api/types/mount"
3224
"github.com/docker/docker/api/types/network"
3325
"github.com/docker/docker/client"
3426
"github.com/docker/docker/pkg/stdcopy"
27+
"github.com/go-git/go-billy/v5/helper/polyfill"
28+
"github.com/go-git/go-billy/v5/osfs"
29+
"github.com/go-git/go-git/v5/plumbing/format/gitignore"
30+
"github.com/imdario/mergo"
31+
"github.com/joho/godotenv"
32+
"github.com/kballard/go-shellquote"
3533
specs "github.com/opencontainers/image-spec/specs-go/v1"
36-
37-
"github.com/Masterminds/semver"
34+
"github.com/spf13/pflag"
3835
"golang.org/x/term"
3936

4037
"github.com/nektos/act/pkg/common"
@@ -484,11 +481,17 @@ func (cr *containerReference) extractFromImageEnv(env *map[string]string) common
484481
inspect, _, err := cr.cli.ImageInspectWithRaw(ctx, cr.input.Image)
485482
if err != nil {
486483
logger.Error(err)
484+
return fmt.Errorf("inspect image: %w", err)
485+
}
486+
487+
if inspect.Config == nil {
488+
return nil
487489
}
488490

489491
imageEnv, err := godotenv.Unmarshal(strings.Join(inspect.Config.Env, "\n"))
490492
if err != nil {
491493
logger.Error(err)
494+
return fmt.Errorf("unmarshal image env: %w", err)
492495
}
493496

494497
for k, v := range imageEnv {

0 commit comments

Comments
 (0)