diff --git a/.github/workflows/automation.yml b/.github/workflows/automation.yml index 65d43ad..6b94c67 100644 --- a/.github/workflows/automation.yml +++ b/.github/workflows/automation.yml @@ -23,6 +23,7 @@ jobs: env: BIBLE_API_URL: ${{ secrets.BIBLE_API_URL }} BIBLE_API_KEY: ${{ secrets.BIBLE_API_KEY }} + GCLOUD_PROJECT_ID: ${{ secrets.GCLOUD_PROJECT_ID }} run: | go mod tidy go test github.com/julwrites/ScriptureBot/pkg/utils \ diff --git a/pkg/app/api_client.go b/pkg/app/api_client.go index 3578a59..838afc1 100644 --- a/pkg/app/api_client.go +++ b/pkg/app/api_client.go @@ -56,9 +56,18 @@ func getAPIConfig(projectID string) (string, string) { // If env vars are missing, try to fetch from Secret Manager if url == "" || key == "" { - envProjectID := os.Getenv("GCLOUD_PROJECT_ID") - if envProjectID != "" { - projectID = envProjectID + // Try to fetch project ID first from env + if projectID == "" { + projectID := os.Getenv("GCLOUD_PROJECT_ID") + + // Then from secrets + if projectID == "" { + var err error + projectID, err = getSecretFunc(projectID, "GCLOUD_PROJECT_ID") + if err != nil { + log.Printf("Failed to fetch GCLOUD_PROJECT_ID from Secret Manager: %v", err) + } + } } if projectID != "" { diff --git a/pkg/bot/bot.go b/pkg/bot/bot.go index 582cee7..cadceae 100644 --- a/pkg/bot/bot.go +++ b/pkg/bot/bot.go @@ -6,7 +6,6 @@ package bot import ( "fmt" "log" - "os" "github.com/julwrites/BotPlatform/pkg/def" @@ -28,9 +27,6 @@ func RunCommands(env def.SessionData) def.SessionData { env.Msg.Command = app.CMD_CLOSE } - // Propagate secrets - env.Secrets.PROJECT_ID = os.Getenv("GCLOUD_PROJECT_ID") - env = app.ProcessCommand(env) return env