Skip to content

Commit

Permalink
Merge pull request #58 from atomist-skills/feat/detect-environment
Browse files Browse the repository at this point in the history
feat: add `IsStaging()` function to detect the running environment
  • Loading branch information
mcapell authored Feb 16, 2024
2 parents a0da367 + 30cf50c commit 732c2e5
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions util/environment.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package util

import (
"os"
"strings"
)

// Return whether the skill runs on staging or not, using the same logic as the TypeScript code.
// ref: https://github.com/atomist-skills/skill/blob/21696f154efded41f4cb98eb0e6951ab81839b8c/lib/util.ts#L235-L240
func IsStaging() bool {
url, found := os.LookupEnv("ATOMIST_GRAPHQL_ENDPOINT")
if !found {
url = "https://automation.atomist.com/graphql"
}

return strings.Contains(url, "-stage")
}

0 comments on commit 732c2e5

Please sign in to comment.