Skip to content

Commit fdc5ae3

Browse files
committed
Add IsActionsWorkflow
1 parent e250c71 commit fdc5ae3

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

go/extractor/cli/go-autobuilder/go-autobuilder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ func installDependenciesAndBuild() {
565565
// Go tooling should install required Go versions as needed.
566566
if toolchain.GetEnvGoSemVer().IsOlderThan(toolchain.V1_21) && greatestGoVersion != nil && greatestGoVersion.IsNewerThan(toolchain.GetEnvGoSemVer()) {
567567
diagnostics.EmitNewerGoVersionNeeded(toolchain.GetEnvGoSemVer().String(), greatestGoVersion.String())
568-
if val, _ := os.LookupEnv("GITHUB_ACTIONS"); val == "true" {
568+
if util.IsActionsWorkflow() {
569569
log.Printf(
570570
"A go.mod file requires version %s of Go, but version %s is installed. Consider adding an actions/setup-go step to your workflow.\n",
571571
greatestGoVersion,

go/extractor/util/util.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,12 @@ func IsGolangVendorDirectory(dirPath string) bool {
313313
fileExists(filepath.Join(dirPath, "../vendor.conf")))
314314
}
315315

316+
// Returns true if the `GITHUB_ACTIONS` environment variable is set to `true`.
317+
// This is the case in GitHub Actions workflows.
318+
func IsActionsWorkflow() bool {
319+
return os.Getenv("GITHUB_ACTIONS") == "true"
320+
}
321+
316322
// Returns true if the `GITHUB_EVENT_NAME` environment variable is set and suggests that
317323
// we are running in a GitHub Actions workflow that was triggered by the `dynamic` event.
318324
// This is the case for e.g. Default Setup.

0 commit comments

Comments
 (0)