From 56b45812dbee8fa981aa8b922da7e50849830917 Mon Sep 17 00:00:00 2001 From: Muhammad Razin Syakib Date: Wed, 28 Aug 2024 09:25:14 +0700 Subject: [PATCH] [C8 BE*] connect to supabase db --- .github/workflows/deployment.yaml | 80 ++++++++++++++++++++----------- knexfile.ts | 28 +++++------ 2 files changed, 67 insertions(+), 41 deletions(-) diff --git a/.github/workflows/deployment.yaml b/.github/workflows/deployment.yaml index eb9effd..a39688e 100644 --- a/.github/workflows/deployment.yaml +++ b/.github/workflows/deployment.yaml @@ -1,42 +1,68 @@ -name: CICD Deployment API to Elastic Beanstalk +name: CICD Deployment API Koyeb on: push: branches: - Ch8BE + pull_request: + branches: + - Ch8BE jobs: - build-and-deploy: - runs-on: [ ubuntu-latest ] + build: + runs-on: ubuntu-latest + steps: - - name: Checkout Source - uses: actions/checkout@v2 - - name: Setup Node - uses: actions/setup-node@v4 + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup Node.js + uses: actions/setup-node@v3 with: - node-version: 20 + node-version: '20' + + - name: Install dependencies + run: yarn install - - name: Install Yarn - run: npm install --global yarn@latest + # - name: Run tests + # run: npm test - - name: Clean Yarn Cache - run: yarn cache clean + # - name: Build project + # run: npm run build - - name: Remove Node Modules - run: rm -rf node_modules + deploy: + runs-on: ubuntu-latest + needs: build + if: github.ref == 'refs/heads/Ch8BE' - - name: Install Dependencies - run: yarn install --frozen-lockfile - - name: Generate deployment package - run: zip -r deploy.zip . -x '*.git*' - - name: Deploy to EB - uses: einaregilsson/beanstalk-deploy@v22 + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup Node.js + uses: actions/setup-node@v3 with: - aws_access_key: ${{ secrets.AWS_ACCESS_KEY }} - aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - application_name: 'Car-Challenge8-API' - environment_name: 'car-challenge8-api-env' - version_label: ${{ github.sha }}-${{ github.run_number }} - region: us-east-1 - deployment_package: deploy.zip \ No newline at end of file + node-version: '20' + + - name: Install dependencies + run: yarn install + + - name: Build project + run: npm run build + + - name: Deploy to Koyeb + env: + KOYEB_API_TOKEN: 7mn92452fwp2net3olqnxly8glbq0a6ejnwb603ntbb51w0smc7vzi92h0vkugzd + run: | + curl -X POST https://app.koyeb.com/v1/services/c7ae7002-8df6-48f9-ad18-fbd5fa336ebf/redeploy \ + -H "Authorization: Bearer 7mn92452fwp2net3olqnxly8glbq0a6ejnwb603ntbb51w0smc7vzi92h0vkugzd" \ + -H "Content-Type: application/json" \ + -d ' + { + "name": "synrgy-final-project-fsw", + "git": { + "repo":"https://github.com/RazinSyakib43/Car-Management-Dashboard.git", + "branch":"Ch8BE" + } + }' \ No newline at end of file diff --git a/knexfile.ts b/knexfile.ts index 156ac4a..7118bc7 100644 --- a/knexfile.ts +++ b/knexfile.ts @@ -4,14 +4,8 @@ import type { Knex } from "knex"; const config: { [key: string]: Knex.Config } = { development: { - client: "pg", - connection: { - host: "localhost", - port: 5432, - database: "car_rental_ch7_db", - user: "postgres", - password: "yessgood123", - }, + client: 'pg', + connection: "postgresql://postgres.hgxmajbxzfwodrzbdpmc:oQxil5ODW3SK@aws-0-us-east-1.pooler.supabase.com:6543/postgres", pool: { min: 0, max: 7 @@ -28,9 +22,12 @@ const config: { [key: string]: Knex.Config } = { staging: { client: "postgresql", connection: { - database: "my_db", - user: "username", - password: "password" + host: "carrentalch7db.cjss6eo44hm5.ap-southeast-1.rds.amazonaws.com", + port: 5432, + database: "car_rental_ch7_db", + user: "ch8admin", + password: "oQxil5ODW3SK", + ssl: { rejectUnauthorized: false } }, pool: { min: 2, @@ -44,9 +41,12 @@ const config: { [key: string]: Knex.Config } = { production: { client: "postgresql", connection: { - database: "my_db", - user: "username", - password: "password" + host: "carrentalch7db.cjss6eo44hm5.ap-southeast-1.rds.amazonaws.com", + port: 5432, + database: "car_rental_ch7_db", + user: "ch8admin", + password: "oQxil5ODW3SK", + ssl: { rejectUnauthorized: false } }, pool: { min: 2,