Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: job platform (#15716)

Danny Xu4bf157ecd513
diff --git a/action/main.go b/action/main.go
index 15eded01d4..f9f721e898 100644
--- a/action/main.go
+++ b/action/main.go
@@ -5,5 +5,6 @@ import (
)
func main() {
- fmt.Println("Hello, World!")
-}
\ No newline at end of file
+ platform := getJobPlatform()
+ fmt.Printf("Hello, World - %s!", platform.String())
+}
diff --git a/action/platform.go b/action/platform.go
new file mode 100644
index 0000000000..a5c96a741e
--- /dev/null
+++ b/action/platform.go
@@ -0,0 +1,51 @@
+package main
+
+import "os"
+
+// JobPlatform represents the supported CI/CD platforms.
+type JobPlatform int
+
+const (
+ LocalPlatform JobPlatform = iota
+ GitHub
+ GitLab
+ Bitbucket
+ AzureDevOps
+)
+
+// String returns the string representation of the JobPlatform enum.
+func (p JobPlatform) String() string {
+ switch p {
+ case GitHub:
+ return "GitHub"
+ case GitLab:
+ return "GitLab"
+ case Bitbucket:
+ return "Bitbucket"
+ case AzureDevOps:
+ return "Azure DevOps"
+ default:
+ return "Local"
+ }
+}
+
+// getJobPlatform returns the platform where the job is running as a JobPlatform.
+func getJobPlatform() JobPlatform {
+ // https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables
+ if os.Getenv("GITHUB_ACTIONS") == "true" {
+ return GitHub
+ }
+ // https://docs.gitlab.com/ci/variables/predefined_variables/
+ if os.Getenv("GITLAB_CI") == "true" {
+ return GitLab
+ }
+ // https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/
+ if os.Getenv("BITBUCKET_BUILD_NUMBER") != "" {
+ return Bitbucket
+ }
+ // https://learn.microsoft.com/en-us/azure/devops/pipelines/release/variables?view=azure-devops
+ if os.Getenv("SYSTEM_TEAMFOUNDATIONSERVERURI") != "" {
+ return AzureDevOps
+ }
+ return LocalPlatform
+}