From 3952b4b5d7331d410b7c6e4efb515b583f4d8787 Mon Sep 17 00:00:00 2001 From: "son.tran" Date: Mon, 20 Nov 2023 16:55:15 +0700 Subject: [PATCH] feat(master): add database --- .github/workflows/deploy-api.yml | 2 +- apps/api/Makefile | 4 +--- apps/api/db/connectDB.go | 4 +--- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/deploy-api.yml b/.github/workflows/deploy-api.yml index f0ba0ab..5c63aaa 100644 --- a/.github/workflows/deploy-api.yml +++ b/.github/workflows/deploy-api.yml @@ -42,5 +42,5 @@ jobs: cd apps/api rm -rf .env touch .env - echo "DSN=124124" >> .env + echo "DSN=${{ secrets.DSN }}" >> .env pnpm run deploy diff --git a/apps/api/Makefile b/apps/api/Makefile index 84504cf..bf0de31 100644 --- a/apps/api/Makefile +++ b/apps/api/Makefile @@ -5,9 +5,7 @@ dev: migration: go run migrate/main.go build: clean - source .env - EXTRA_VARS=$(shell echo $EXTRA_VARS) - env GOOS=linux GOARCH=amd64 CGO_ENABLED=0 $(EXTRA_VARS) go build -ldflags="-s -w" -o bin/api router/main.go + env GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w" -o bin/api router/main.go zip bin/api.zip bin/api deploy: build sls deploy diff --git a/apps/api/db/connectDB.go b/apps/api/db/connectDB.go index 3bb6153..f6186c1 100644 --- a/apps/api/db/connectDB.go +++ b/apps/api/db/connectDB.go @@ -13,9 +13,7 @@ import ( var DB *gorm.DB func ConnectDB() { - if err := godotenv.Load(); err != nil { - log.Fatal("failed to load env", err) - } + godotenv.Load() var err error DB, err = gorm.Open(mysql.Open(os.Getenv("DSN")), &gorm.Config{}) if err != nil {