Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
15 changes: 12 additions & 3 deletions pkg/app/api_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 != "" {
Expand Down
4 changes: 0 additions & 4 deletions pkg/bot/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package bot
import (
"fmt"
"log"
"os"

"github.com/julwrites/BotPlatform/pkg/def"

Expand All @@ -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
Expand Down
Loading