From 4c0ba794c566f099204b3c662fc4024b9b9e3c48 Mon Sep 17 00:00:00 2001 From: bentran1vn Date: Sat, 28 Sep 2024 01:38:24 +0700 Subject: [PATCH] Adding Config --- .github/workflows/my-jobs.yml | 33 +++++++++++++++----- .gitignore | 3 +- MBS-COMMAND.API/appsettings.Development.json | 4 +-- MBS-COMMAND.API/appsettings.json | 4 +-- 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/.github/workflows/my-jobs.yml b/.github/workflows/my-jobs.yml index 959f207..6a2edc8 100644 --- a/.github/workflows/my-jobs.yml +++ b/.github/workflows/my-jobs.yml @@ -1,18 +1,34 @@ -name: My Jobs +name: CI/CD Pipeline + on: push: + branches: + - '*' # Matches every branch + - '!main' # Excludes main branch + pull_request: + types: + - closed branches: - main jobs: - build_and_deploy: - runs-on: [self-hosted] - env: - CONTAINER_NAME: myappCommandContainer + build: + runs-on: [ self-hosted ] steps: - uses: actions/checkout@v3 - name: Build Docker Image run: docker build -t myapp-command:latest -f MBS-COMMAND.API/Dockerfile . - - name: Manage Docker Container and Build + + deploy: + needs: build + runs-on: [self-hosted] + if: github.event_name == 'pull_request' && github.event.pull_request.merged == true + env: + CONTAINER_NAME: myappCommandContainer + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Deploy to Server run: | CNAME=${{ env.CONTAINER_NAME }} @@ -34,4 +50,7 @@ jobs: fi # Run new container echo ":: Running new container - $CNAME" - docker run -d --network=MBS --name $CNAME myapp-command:latest + docker run -d --network=MBS -p 4000:8080 --name $CNAME myapp-command:latest + + - name: Notify Deployment + run: echo "Deployment completed successfully!" diff --git a/.gitignore b/.gitignore index 90431f4..9757792 100644 --- a/.gitignore +++ b/.gitignore @@ -477,4 +477,5 @@ Temporary Items # End of https://www.toptal.com/developers/gitignore/api/macos,rider,intellij,aspnetcore,dotnetcore -docker-compose.yml \ No newline at end of file +docker-compose.yml +MBS-COMMAND.API/logs \ No newline at end of file diff --git a/MBS-COMMAND.API/appsettings.Development.json b/MBS-COMMAND.API/appsettings.Development.json index 486c814..8a72d54 100644 --- a/MBS-COMMAND.API/appsettings.Development.json +++ b/MBS-COMMAND.API/appsettings.Development.json @@ -1,7 +1,7 @@ { "ConnectionStrings": { - "ConnectionStrings": "Server=14.225.205.54;Database=AntreeDB;Uid=sa;Pwd=Thientan291157@;Trust Server Certificate=True;", - "Redis": "103.162.14.116:6379" + "ConnectionStrings": "Server=103.162.14.116;Database=PRN_SUPER;Uid=sa;Pwd=MyStrongPassword123@;Trust Server Certificate=True;", + "Redis": "103.162.14.116:6379,password=MyStrongPassword123@,abortConnect=false" }, "JwtOption": { "Issuer": "http://103.162.14.116:8080", diff --git a/MBS-COMMAND.API/appsettings.json b/MBS-COMMAND.API/appsettings.json index faa5c0b..aa9dcf4 100644 --- a/MBS-COMMAND.API/appsettings.json +++ b/MBS-COMMAND.API/appsettings.json @@ -1,7 +1,7 @@ { "ConnectionStrings": { - "ConnectionStrings": "Server=14.225.205.54;Database=AntreeDB;Uid=sa;Pwd=Thientan291157@;Trust Server Certificate=True;", - "Redis": "103.162.14.116:6379" + "ConnectionStrings": "Server=103.162.14.116;Database=PRN_SUPER;Uid=sa;Pwd=MyStrongPassword123@;Trust Server Certificate=True;", + "Redis": "103.162.14.116:6379,password=MyStrongPassword123@,abortConnect=false" }, "JwtOption": { "Issuer": "http://103.162.14.116:8080",