Skip to content

Commit

Permalink
attempting github actions error fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
EricFrancis12 committed Jun 27, 2024
1 parent 15f9c94 commit b2be115
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

- run: npm ci

- run: prisma generate
- run: npx prisma generate
- run: make db push
- run: make seed

Expand Down
24 changes: 23 additions & 1 deletion api.dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func NewAPIServer(listenAddr string) *APIServer {
}

func main() {
if err := godotenv.Load(".env.local", ".env"); err != nil {
if err := SafeLoadEnvs(".env.local", ".env"); err != nil {
log.Fatal("error loading .env files: " + err.Error())
}
if err := os.Setenv("NODE_ENV", "development"); err != nil {
Expand Down Expand Up @@ -85,6 +85,28 @@ func TCPPortOpen(host string, port string) bool {
return true
}

func SafeLoadEnvs(filenames ...string) error {
validFilenames := []string{}
for _, fn := range filenames {
if fileExists(fn) {
validFilenames = append(validFilenames, fn)
}
}
if len(validFilenames) == 0 {
fmt.Println("No env files found")
return nil
}
return godotenv.Load(validFilenames...)
}

func fileExists(filepath string) bool {
_, err := os.Stat(filepath)
if os.IsNotExist(err) {
return false
}
return err == nil
}

func contentType(f string) string {
spl := strings.Split(f, ".")
fext := spl[len(spl)-1]
Expand Down

0 comments on commit b2be115

Please sign in to comment.