From eeef707993a72b2ff9eb7ae3217ae5787d80d03b Mon Sep 17 00:00:00 2001 From: dhruv Date: Wed, 27 Mar 2024 19:49:42 +0530 Subject: [PATCH] cd testing Signed-off-by: dhruv --- .github/workflows/cd.yml | 48 +++++++++++++++++++++++++++++++++++----- create_prose.go | 4 ++-- go.mod | 2 +- main.go | 10 ++++++--- prose.go | 4 ++-- users.go | 4 ++-- 6 files changed, 56 insertions(+), 16 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index b304413..47a2465 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -1,11 +1,47 @@ name: cd on: - workflow_dispatch: - push: - branches: [main] - pull_request: - branches: [main] + workflow_dispatch: + push: + branches: [main] + pull_request: + branches: [main] jobs: - \ No newline at end of file + deploy: + name: deploy + runs-on: ubuntu-latest + + steps: + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "1.21" + + - name: Checkout code + uses: actions/checkout@v3 + + - name: Build the app + run: ./scripts/build.sh + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ap-south-1 + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + + - name: Build, tag, and push image to Amazon ECR + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: verses + IMAGE_TAG: verses:latest + run: | + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + \ No newline at end of file diff --git a/create_prose.go b/create_prose.go index 532ef30..5aa41ac 100644 --- a/create_prose.go +++ b/create_prose.go @@ -10,8 +10,8 @@ import ( "github.com/go-chi/chi/v5" "github.com/google/uuid" - auth "github.com/jaydee029/Barkin/internal" - "github.com/jaydee029/Barkin/internal/database" + auth "github.com/jaydee029/Verses/internal" + "github.com/jaydee029/Verses/internal/database" ) type Res struct { diff --git a/go.mod b/go.mod index fbb8ff9..c834837 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/jaydee029/Barkin +module github.com/jaydee029/Verses go 1.20 diff --git a/main.go b/main.go index f45ce26..a27c73a 100644 --- a/main.go +++ b/main.go @@ -10,7 +10,7 @@ import ( _ "github.com/lib/pq" "github.com/go-chi/chi/v5" - "github.com/jaydee029/Barkin/internal/database" + "github.com/jaydee029/Verses/internal/database" "github.com/joho/godotenv" ) @@ -22,8 +22,12 @@ type apiconfig struct { } func main() { - godotenv.Load(".env") - + err := godotenv.Load(".env") + /* + if err != nil { + log.Fatal(".env file not provided") + } + */ jwt_secret := os.Getenv("JWT_SECRET") if jwt_secret == "" { log.Fatal("JWT secret key not set") diff --git a/prose.go b/prose.go index aa9aafe..97387be 100644 --- a/prose.go +++ b/prose.go @@ -7,8 +7,8 @@ import ( "github.com/go-chi/chi/v5" "github.com/google/uuid" - auth "github.com/jaydee029/Barkin/internal" - "github.com/jaydee029/Barkin/internal/database" + auth "github.com/jaydee029/Verses/internal" + "github.com/jaydee029/Verses/internal/database" ) type Prose struct { diff --git a/users.go b/users.go index cd96d7e..93ca66c 100644 --- a/users.go +++ b/users.go @@ -6,8 +6,8 @@ import ( "time" "github.com/google/uuid" - auth "github.com/jaydee029/Barkin/internal" - "github.com/jaydee029/Barkin/internal/database" + auth "github.com/jaydee029/Verses/internal" + "github.com/jaydee029/Verses/internal/database" "golang.org/x/crypto/bcrypt" )