Skip to content

Commit e6fec73

Browse files
author
techknowlogick
committed
Merge pull request 'Bump nektos/act to 0.2.59' (#90) from harryzcy/act:bump-nektos-act into main
Reviewed-on: https://gitea.com/gitea/act/pulls/90
2 parents 15045b4 + 73f3288 commit e6fec73

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1102
-356
lines changed

.github/workflows/checks.yml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ jobs:
1515
name: lint
1616
runs-on: ubuntu-latest
1717
steps:
18-
- uses: actions/checkout@v3
18+
- uses: actions/checkout@v4
1919
with:
2020
fetch-depth: 0
21-
- uses: actions/setup-go@v4
21+
- uses: actions/setup-go@v5
2222
with:
2323
go-version-file: go.mod
2424
check-latest: true
2525
- uses: golangci/[email protected]
2626
with:
2727
version: v1.53
2828
only-new-issues: true
29-
- uses: megalinter/megalinter/flavors/go@v7.4.0
29+
- uses: megalinter/megalinter/flavors/go@v7.8.0
3030
env:
3131
DEFAULT_BRANCH: master
3232
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -38,12 +38,12 @@ jobs:
3838
name: test-linux
3939
runs-on: ubuntu-latest
4040
steps:
41-
- uses: actions/checkout@v3
41+
- uses: actions/checkout@v4
4242
with:
4343
fetch-depth: 2
4444
- name: Set up QEMU
4545
uses: docker/setup-qemu-action@v3
46-
- uses: actions/setup-go@v4
46+
- uses: actions/setup-go@v5
4747
with:
4848
go-version-file: go.mod
4949
check-latest: true
@@ -61,7 +61,7 @@ jobs:
6161
- name: Run act from cli
6262
run: go run main.go -P ubuntu-latest=node:16-buster-slim -C ./pkg/runner/testdata/ -W ./basic/push.yml
6363
- name: Upload Codecov report
64-
uses: codecov/[email protected].4
64+
uses: codecov/[email protected].5
6565
with:
6666
files: coverage.txt
6767
fail_ci_if_error: true # optional (default = false)
@@ -75,10 +75,10 @@ jobs:
7575
name: test-${{matrix.os}}
7676
runs-on: ${{matrix.os}}
7777
steps:
78-
- uses: actions/checkout@v3
78+
- uses: actions/checkout@v4
7979
with:
8080
fetch-depth: 2
81-
- uses: actions/setup-go@v4
81+
- uses: actions/setup-go@v5
8282
with:
8383
go-version-file: go.mod
8484
check-latest: true
@@ -92,8 +92,8 @@ jobs:
9292
name: snapshot
9393
runs-on: ubuntu-latest
9494
steps:
95-
- uses: actions/checkout@v3
96-
- uses: actions/setup-go@v4
95+
- uses: actions/checkout@v4
96+
- uses: actions/setup-go@v5
9797
with:
9898
go-version-file: go.mod
9999
check-latest: true
@@ -111,67 +111,67 @@ jobs:
111111
args: release --snapshot --clean
112112
- name: Capture x86_64 (64-bit) Linux binary
113113
if: ${{ !env.ACT }}
114-
uses: actions/upload-artifact@v3
114+
uses: actions/upload-artifact@v4
115115
with:
116116
name: act-linux-amd64
117117
path: dist/act_linux_amd64_v1/act
118118
- name: Capture i386 (32-bit) Linux binary
119119
if: ${{ !env.ACT }}
120-
uses: actions/upload-artifact@v3
120+
uses: actions/upload-artifact@v4
121121
with:
122122
name: act-linux-i386
123123
path: dist/act_linux_386/act
124124
- name: Capture arm64 (64-bit) Linux binary
125125
if: ${{ !env.ACT }}
126-
uses: actions/upload-artifact@v3
126+
uses: actions/upload-artifact@v4
127127
with:
128128
name: act-linux-arm64
129129
path: dist/act_linux_arm64/act
130130
- name: Capture armv6 (32-bit) Linux binary
131131
if: ${{ !env.ACT }}
132-
uses: actions/upload-artifact@v3
132+
uses: actions/upload-artifact@v4
133133
with:
134134
name: act-linux-armv6
135135
path: dist/act_linux_arm_6/act
136136
- name: Capture armv7 (32-bit) Linux binary
137137
if: ${{ !env.ACT }}
138-
uses: actions/upload-artifact@v3
138+
uses: actions/upload-artifact@v4
139139
with:
140140
name: act-linux-armv7
141141
path: dist/act_linux_arm_7/act
142142
- name: Capture x86_64 (64-bit) Windows binary
143143
if: ${{ !env.ACT }}
144-
uses: actions/upload-artifact@v3
144+
uses: actions/upload-artifact@v4
145145
with:
146146
name: act-windows-amd64
147147
path: dist/act_windows_amd64_v1/act.exe
148148
- name: Capture i386 (32-bit) Windows binary
149149
if: ${{ !env.ACT }}
150-
uses: actions/upload-artifact@v3
150+
uses: actions/upload-artifact@v4
151151
with:
152152
name: act-windows-i386
153153
path: dist/act_windows_386/act.exe
154154
- name: Capture arm64 (64-bit) Windows binary
155155
if: ${{ !env.ACT }}
156-
uses: actions/upload-artifact@v3
156+
uses: actions/upload-artifact@v4
157157
with:
158158
name: act-windows-arm64
159159
path: dist/act_windows_arm64/act.exe
160160
- name: Capture armv7 (32-bit) Windows binary
161161
if: ${{ !env.ACT }}
162-
uses: actions/upload-artifact@v3
162+
uses: actions/upload-artifact@v4
163163
with:
164164
name: act-windows-armv7
165165
path: dist/act_windows_arm_7/act.exe
166166
- name: Capture x86_64 (64-bit) MacOS binary
167167
if: ${{ !env.ACT }}
168-
uses: actions/upload-artifact@v3
168+
uses: actions/upload-artifact@v4
169169
with:
170170
name: act-macos-amd64
171171
path: dist/act_darwin_amd64_v1/act
172172
- name: Capture arm64 (64-bit) MacOS binary
173173
if: ${{ !env.ACT }}
174-
uses: actions/upload-artifact@v3
174+
uses: actions/upload-artifact@v4
175175
with:
176176
name: act-macos-arm64
177177
path: dist/act_darwin_arm64/act

.github/workflows/promote.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ jobs:
99
name: promote
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v3
12+
- uses: actions/checkout@v4
1313
with:
1414
fetch-depth: 0
1515
ref: master
1616
token: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
1717
- uses: fregante/setup-git-user@v2
18-
- uses: actions/setup-go@v4
18+
- uses: actions/setup-go@v5
1919
with:
2020
go-version-file: go.mod
2121
check-latest: true

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ jobs:
99
name: release
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v3
12+
- uses: actions/checkout@v4
1313
with:
1414
fetch-depth: 0
15-
- uses: actions/setup-go@v4
15+
- uses: actions/setup-go@v5
1616
with:
1717
go-version-file: go.mod
1818
check-latest: true
@@ -43,7 +43,7 @@ jobs:
4343
apiKey: ${{ secrets.CHOCO_APIKEY }}
4444
push: true
4545
- name: GitHub CLI extension
46-
uses: actions/github-script@v6
46+
uses: actions/github-script@v7
4747
with:
4848
github-token: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
4949
script: |

.github/workflows/stale.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
name: Stale
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/stale@v8
11+
- uses: actions/stale@v9
1212
with:
1313
repo-token: ${{ secrets.GITHUB_TOKEN }}
1414
stale-issue-message: 'Issue is stale and will be closed in 14 days unless there is new activity'

.mergify.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ pull_request_rules:
7171
- and:
7272
- 'approved-reviews-by=@nektos/act-maintainers'
7373
- '#approved-reviews-by>=2'
74+
- and:
75+
- 'author=@nektos/act-maintainers'
76+
- 'approved-reviews-by=@nektos/act-maintainers'
77+
- '#approved-reviews-by>=1'
7478
- -draft
7579
- -merged
7680
- -closed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.2.52
1+
0.2.59

cmd/input.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ type Input struct {
5555
replaceGheActionTokenWithGithubCom string
5656
matrix []string
5757
actionCachePath string
58+
actionOfflineMode bool
5859
logPrefixJobID bool
60+
networkName string
61+
useNewActionCache bool
5962
}
6063

6164
func (i *Input) resolve(path string) string {

cmd/platforms.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func (i *Input) newPlatforms() map[string]string {
1515
for _, p := range i.platforms {
1616
pParts := strings.Split(p, "=")
1717
if len(pParts) == 2 {
18-
platforms[pParts[0]] = pParts[1]
18+
platforms[strings.ToLower(pParts[0])] = pParts[1]
1919
}
2020
}
2121
return platforms

cmd/root.go

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/AlecAivazis/survey/v2"
1515
"github.com/adrg/xdg"
1616
"github.com/andreaskoch/go-fswatch"
17+
docker_container "github.com/docker/docker/api/types/container"
1718
"github.com/joho/godotenv"
1819
gitignore "github.com/sabhiram/go-gitignore"
1920
log "github.com/sirupsen/logrus"
@@ -96,30 +97,32 @@ func Execute(ctx context.Context, version string) {
9697
rootCmd.PersistentFlags().StringVarP(&input.cacheServerAddr, "cache-server-addr", "", common.GetOutboundIP().String(), "Defines the address to which the cache server binds.")
9798
rootCmd.PersistentFlags().Uint16VarP(&input.cacheServerPort, "cache-server-port", "", 0, "Defines the port where the artifact server listens. 0 means a randomly available port.")
9899
rootCmd.PersistentFlags().StringVarP(&input.actionCachePath, "action-cache-path", "", filepath.Join(CacheHomeDir, "act"), "Defines the path where the actions get cached and host workspaces created.")
100+
rootCmd.PersistentFlags().BoolVarP(&input.actionOfflineMode, "action-offline-mode", "", false, "If action contents exists, it will not be fetch and pull again. If turn on this,will turn off force pull")
101+
rootCmd.PersistentFlags().StringVarP(&input.networkName, "network", "", "host", "Sets a docker network name. Defaults to host.")
102+
rootCmd.PersistentFlags().BoolVarP(&input.useNewActionCache, "use-new-action-cache", "", false, "Enable using the new Action Cache for storing Actions locally")
99103
rootCmd.SetArgs(args())
100104

101105
if err := rootCmd.Execute(); err != nil {
102106
os.Exit(1)
103107
}
104108
}
105109

110+
// Return locations where Act's config can be found in order: XDG spec, .actrc in HOME directory, .actrc in invocation directory
106111
func configLocations() []string {
107112
configFileName := ".actrc"
108113

109-
// reference: https://specifications.freedesktop.org/basedir-spec/latest/ar01s03.html
110-
var actrcXdg string
111-
for _, fileName := range []string{"act/actrc", configFileName} {
112-
if foundConfig, err := xdg.SearchConfigFile(fileName); foundConfig != "" && err == nil {
113-
actrcXdg = foundConfig
114-
break
115-
}
116-
}
114+
homePath := filepath.Join(UserHomeDir, configFileName)
115+
invocationPath := filepath.Join(".", configFileName)
117116

118-
return []string{
119-
filepath.Join(UserHomeDir, configFileName),
120-
actrcXdg,
121-
filepath.Join(".", configFileName),
117+
// Though named xdg, adrg's lib support macOS and Windows config paths as well
118+
// It also takes cares of creating the parent folder so we don't need to bother later
119+
specPath, err := xdg.ConfigFile("act/actrc")
120+
if err != nil {
121+
specPath = homePath
122122
}
123+
124+
// This order should be enforced since the survey part relies on it
125+
return []string{specPath, homePath, invocationPath}
123126
}
124127

125128
var commonSocketPaths = []string{
@@ -265,7 +268,8 @@ func readArgsFile(file string, split bool) []string {
265268
}()
266269
scanner := bufio.NewScanner(f)
267270
for scanner.Scan() {
268-
arg := strings.TrimSpace(scanner.Text())
271+
arg := os.ExpandEnv(strings.TrimSpace(scanner.Text()))
272+
269273
if strings.HasPrefix(arg, "-") && split {
270274
args = append(args, regexp.MustCompile(`\s`).Split(arg, 2)...)
271275
} else if !split {
@@ -291,19 +295,17 @@ func cleanup(inputs *Input) func(*cobra.Command, []string) {
291295
}
292296
}
293297

294-
func parseEnvs(env []string, envs map[string]string) bool {
295-
if env != nil {
296-
for _, envVar := range env {
297-
e := strings.SplitN(envVar, `=`, 2)
298-
if len(e) == 2 {
299-
envs[e[0]] = e[1]
300-
} else {
301-
envs[e[0]] = ""
302-
}
298+
func parseEnvs(env []string) map[string]string {
299+
envs := make(map[string]string, len(env))
300+
for _, envVar := range env {
301+
e := strings.SplitN(envVar, `=`, 2)
302+
if len(e) == 2 {
303+
envs[e[0]] = e[1]
304+
} else {
305+
envs[e[0]] = ""
303306
}
304-
return true
305307
}
306-
return false
308+
return envs
307309
}
308310

309311
func readYamlFile(file string) (map[string]string, error) {
@@ -409,13 +411,11 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str
409411
}
410412

411413
log.Debugf("Loading environment from %s", input.Envfile())
412-
envs := make(map[string]string)
413-
_ = parseEnvs(input.envs, envs)
414+
envs := parseEnvs(input.envs)
414415
_ = readEnvs(input.Envfile(), envs)
415416

416417
log.Debugf("Loading action inputs from %s", input.Inputfile())
417-
inputs := make(map[string]string)
418-
_ = parseEnvs(input.inputs, inputs)
418+
inputs := parseEnvs(input.inputs)
419419
_ = readEnvs(input.Inputfile(), inputs)
420420

421421
log.Debugf("Loading secrets from %s", input.Secretfile())
@@ -552,6 +552,7 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str
552552
}
553553
}
554554
if !cfgFound && len(cfgLocations) > 0 {
555+
// The first config location refers to the global config folder one
555556
if err := defaultImageSurvey(cfgLocations[0]); err != nil {
556557
log.Fatal(err)
557558
}
@@ -578,11 +579,12 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str
578579
EventName: eventName,
579580
EventPath: input.EventPath(),
580581
DefaultBranch: defaultbranch,
581-
ForcePull: input.forcePull,
582+
ForcePull: !input.actionOfflineMode && input.forcePull,
582583
ForceRebuild: input.forceRebuild,
583584
ReuseContainers: input.reuseContainers,
584585
Workdir: input.Workdir(),
585586
ActionCacheDir: input.actionCachePath,
587+
ActionOfflineMode: input.actionOfflineMode,
586588
BindWorkdir: input.bindWorkdir,
587589
LogOutput: !input.noOutput,
588590
JSONLogger: input.jsonLogger,
@@ -612,6 +614,12 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str
612614
ReplaceGheActionWithGithubCom: input.replaceGheActionWithGithubCom,
613615
ReplaceGheActionTokenWithGithubCom: input.replaceGheActionTokenWithGithubCom,
614616
Matrix: matrixes,
617+
ContainerNetworkMode: docker_container.NetworkMode(input.networkName),
618+
}
619+
if input.useNewActionCache {
620+
config.ActionCache = &runner.GoGitActionCache{
621+
Path: config.ActionCacheDir,
622+
}
615623
}
616624
r, err := runner.New(config)
617625
if err != nil {

0 commit comments

Comments
 (0)