From 61ddebe2b19846dcc839e80460bacafd91f20b13 Mon Sep 17 00:00:00 2001 From: Eric Cabrel TIOGO Date: Sun, 24 Mar 2024 23:00:28 +0100 Subject: [PATCH] chore: frontend manual deploy (#62) * chore: frontend manual deploy * chore: only build web app package * chore: deploy frontend in production --- .github/workflows/build.yml | 30 +++++++++++++++--- .../{deploy-core.yml => deploy-backend.yml} | 4 +-- .github/workflows/deploy-frontend.yml | 31 +++++++++++++++++++ .gitignore | 1 + apps/web/src/utils/constants.ts | 2 +- vercel.json | 9 +++--- 6 files changed, 65 insertions(+), 12 deletions(-) rename .github/workflows/{deploy-core.yml => deploy-backend.yml} (98%) create mode 100644 .github/workflows/deploy-frontend.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a9bad1eb..31b5c0cb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,20 +1,23 @@ -name: Build Project +name: Build and preview the project on: pull_request: branches: [ main ] +env: + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + TURBO_TEAM: ${{ secrets.TURBO_TEAM }} + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: build: - name: build runs-on: ubuntu-latest env: NODE_ENV: test - TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} - TURBO_TEAM: ${{ secrets.TURBO_TEAM }} MYSQL_ROOT_PASSWORD: root MYSQL_DATABASE: test MYSQL_PORT: 3306 @@ -56,3 +59,22 @@ jobs: - name: Run tests run: yarn test + + preview-frontend: + runs-on: ubuntu-latest + needs: + - build + steps: + - uses: actions/checkout@v4 + - name: Install Yarn 4 + run: | + corepack enable + yarn set version berry + - name: Install Vercel CLI + run: npm install --global vercel@latest + - name: Pull Vercel Environment Information + run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} + - name: Build Project Artifacts + run: vercel build --token=${{ secrets.VERCEL_TOKEN }} + - name: Deploy Project Artifacts to Vercel + run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} diff --git a/.github/workflows/deploy-core.yml b/.github/workflows/deploy-backend.yml similarity index 98% rename from .github/workflows/deploy-core.yml rename to .github/workflows/deploy-backend.yml index 3548e9c3..999efda4 100644 --- a/.github/workflows/deploy-core.yml +++ b/.github/workflows/deploy-backend.yml @@ -1,4 +1,4 @@ -name: Deploy Core Backend +name: Deploy the backend on: push: branches: @@ -18,10 +18,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Copy the core Dockerfile in the root repository run: cp apps/core/Dockerfile . - - name: Build, tag, and push docker image to Amazon ECR env: REGISTRY: public.ecr.aws/x9y5g9l2 diff --git a/.github/workflows/deploy-frontend.yml b/.github/workflows/deploy-frontend.yml new file mode 100644 index 00000000..7cc4ab0f --- /dev/null +++ b/.github/workflows/deploy-frontend.yml @@ -0,0 +1,31 @@ +name: Deploy the frontend +on: + push: + branches: + - main + paths: + - 'apps/web/src/**' + - 'apps/web/public/**' + +env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + +jobs: + deploy: + runs-on: ubuntu-latest + environment: 'Production' + steps: + - uses: actions/checkout@v4 + - name: Install Yarn 4 + run: | + corepack enable + yarn set version berry + - name: Install Vercel CLI + run: npm install --global vercel@latest + - name: Pull Vercel Environment Information + run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} + - name: Build Project Artifacts + run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }} + - name: Deploy Project Artifacts to Vercel + run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }} diff --git a/.gitignore b/.gitignore index 1bde2caa..3654d67f 100644 --- a/.gitignore +++ b/.gitignore @@ -51,3 +51,4 @@ key.txt .yarn/unplugged .yarn/build-state.yml .yarn/install-state.gz +.vercel diff --git a/apps/web/src/utils/constants.ts b/apps/web/src/utils/constants.ts index f7efcc2f..85c07404 100644 --- a/apps/web/src/utils/constants.ts +++ b/apps/web/src/utils/constants.ts @@ -1,4 +1,4 @@ -export const COOKIE_NAME = 'shguid'; +export const COOKIE_NAME = 'snpc_guid'; export const REGEX_EMAIL = /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/; export const IS_DEV = process.env.NEXT_PUBLIC_APP_ENV === 'development'; export const IS_PROD = process.env.NEXT_PUBLIC_APP_ENV === 'production'; diff --git a/vercel.json b/vercel.json index dab0379d..affcfa6d 100644 --- a/vercel.json +++ b/vercel.json @@ -1,6 +1,7 @@ { - "github": { - "enabled": true, - "silent": true - } + "git": { + "deploymentEnabled": false + }, + "buildCommand": "yarn build --filter=...@snipcode/web", + "outputDirectory": "apps/web/.next" }