Skip to content

Commit

Permalink
feat(master): add database
Browse files Browse the repository at this point in the history
  • Loading branch information
thaisonenouvo committed Nov 20, 2023
1 parent 5d9d592 commit 3952b4b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 1 addition & 3 deletions apps/api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 1 addition & 3 deletions apps/api/db/connectDB.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 3952b4b

Please sign in to comment.