From 5a7b9abe33ec2a84c9abd7a213d70fb06d199612 Mon Sep 17 00:00:00 2001 From: Yasin <61509470+wyxogo@users.noreply.github.com> Date: Mon, 8 Jan 2024 18:43:31 +0800 Subject: [PATCH 01/23] Fix: Routes `/api/cors/[...path]` was not configured to run with the Edge Runtime --- app/api/cors/[...path]/route.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/cors/[...path]/route.ts b/app/api/cors/[...path]/route.ts index 0217b12b08f..1f70d663082 100644 --- a/app/api/cors/[...path]/route.ts +++ b/app/api/cors/[...path]/route.ts @@ -40,4 +40,4 @@ export const POST = handle; export const GET = handle; export const OPTIONS = handle; -export const runtime = "nodejs"; +export const runtime = "edge"; From 31d9d2efcd5cb366cb17e18d09198c0c627c5542 Mon Sep 17 00:00:00 2001 From: Fred Liang Date: Mon, 22 Jan 2024 15:06:41 +0800 Subject: [PATCH 02/23] feat: support setting up GTM --- app/config/server.ts | 2 ++ app/layout.tsx | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/config/server.ts b/app/config/server.ts index c6251a5c262..c455d0b7336 100644 --- a/app/config/server.ts +++ b/app/config/server.ts @@ -89,6 +89,8 @@ export const getServerSideConfig = () => { googleApiKey: process.env.GOOGLE_API_KEY, googleUrl: process.env.GOOGLE_URL, + gtmId: process.env.GTM_ID, + needCode: ACCESS_CODES.size > 0, code: process.env.CODE, codes: ACCESS_CODES, diff --git a/app/layout.tsx b/app/layout.tsx index be2162475d8..2c89ba4944e 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -6,7 +6,7 @@ import { getClientConfig } from "./config/client"; import { type Metadata } from "next"; import { SpeedInsights } from "@vercel/speed-insights/next"; import { getServerSideConfig } from "./config/server"; - +import { GoogleTagManager } from "@next/third-parties/google"; const serverConfig = getServerSideConfig(); export const metadata: Metadata = { @@ -46,6 +46,11 @@ export default function RootLayout({ )} + {serverConfig?.gtmId && ( + <> + + + )} ); From b9995e7f701b4a78ede62da686049c12ab8be092 Mon Sep 17 00:00:00 2001 From: Fred Liang Date: Mon, 22 Jan 2024 15:08:34 +0800 Subject: [PATCH 03/23] feat: update dependencies --- package.json | 1 + yarn.lock | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/package.json b/package.json index a014c7bfe14..f28a5a6ecf2 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "dependencies": { "@fortaine/fetch-event-source": "^3.0.6", "@hello-pangea/dnd": "^16.5.0", + "@next/third-parties": "^14.1.0", "@svgr/webpack": "^6.5.1", "@vercel/analytics": "^0.1.11", "@vercel/speed-insights": "^1.0.2", diff --git a/yarn.lock b/yarn.lock index bf07c27eea1..db6da708b8b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1275,6 +1275,13 @@ resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.4.9.tgz#0c2758164cccd61bc5a1c6cd8284fe66173e4a2b" integrity sha512-QbT03FXRNdpuL+e9pLnu+XajZdm/TtIXVYY4lA9t+9l0fLZbHXDYEKitAqxrOj37o3Vx5ufxiRAniaIebYDCgw== +"@next/third-parties@^14.1.0": + version "14.1.0" + resolved "https://registry.yarnpkg.com/@next/third-parties/-/third-parties-14.1.0.tgz#d9604fff8880e05d3804d2cf7ab42eb5430aec69" + integrity sha512-f55SdvQ1WWxi4mb5QqtYQh5wRzbm1XaeP7s39DPn4ks3re+n9VlFccbMxBRHqkE62zAyIKmvkUB2cByT/gugGA== + dependencies: + third-party-capital "1.0.20" + "@nodelib/fs.scandir@2.1.5": version "2.1.5" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" @@ -5780,6 +5787,11 @@ text-table@^0.2.0: resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" integrity sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw== +third-party-capital@1.0.20: + version "1.0.20" + resolved "https://registry.yarnpkg.com/third-party-capital/-/third-party-capital-1.0.20.tgz#e218a929a35bf4d2245da9addb8ab978d2f41685" + integrity sha512-oB7yIimd8SuGptespDAZnNkzIz+NWaJCu2RMsbs4Wmp9zSDUM8Nhi3s2OOcqYuv3mN4hitXc8DVx+LyUmbUDiA== + through@^2.3.8: version "2.3.8" resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" From 7ec29c2eeaa29fec99a55f9005341f745848e0e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E9=AB=98=E7=8C=9B?= Date: Wed, 24 Jan 2024 20:19:39 +0800 Subject: [PATCH 04/23] add workflows/deploy preview --- .github/workflows/deploy_preview.yml | 82 +++++++++++++++++++++ .github/workflows/remove_deploy_preview.yml | 40 ++++++++++ 2 files changed, 122 insertions(+) create mode 100644 .github/workflows/deploy_preview.yml create mode 100644 .github/workflows/remove_deploy_preview.yml diff --git a/.github/workflows/deploy_preview.yml b/.github/workflows/deploy_preview.yml new file mode 100644 index 00000000000..7bc245ddc3e --- /dev/null +++ b/.github/workflows/deploy_preview.yml @@ -0,0 +1,82 @@ +name: VercelPreviewDeployment + +env: + VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + VERCEL_DOMAIN_SUFFIX: ".pr.nextchat.dev" + +permissions: + contents: read + statuses: write + pull-requests: write + +on: + pull_request: + types: + - opened + - synchronize + +jobs: + deploy-preview: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Extract branch name + shell: bash + run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> "$GITHUB_OUTPUT" + id: extract_branch + + - name: Hash branch name + uses: pplanel/hash-calculator-action@v1.3.1 + id: hash_branch + with: + input: ${{ steps.extract_branch.outputs.branch }} + method: MD5 + + - name: Set Environment Variables + id: set_env + if: github.event_name == 'pull_request' + run: | + echo "VERCEL_ALIAS_DOMAIN=${{ github.event.pull_request.number }}-${{ github.workflow }}.${VERCEL_DOMAIN_SUFFIX}" >> $GITHUB_OUTPUT + + - name: Install Vercel CLI + run: npm install --global vercel@latest + + - name: Cache dependencies + uses: actions/cache@v2 + id: cache-npm + with: + path: ~/.npm + key: npm-${{ hashFiles('package-lock.json') }} + restore-keys: npm- + + - name: Pull Vercel Environment Information + run: vercel pull --yes --environment=preview --token=${VERCEL_TOKEN} + + - name: Deploy Project Artifacts to Vercel + id: vercel + env: + META_TAG: ${{ steps.hash_branch.outputs.digest }}-${{ github.run_number }}-${{ github.run_attempt}} + run: | + env + vercel pull --yes --environment=preview --token=${VERCEL_TOKEN} + vercel build --token=${VERCEL_TOKEN} + vercel deploy --prebuilt --archive=tgz --token=${VERCEL_TOKEN} --meta base_hash=${{ env.META_TAG }} + + vercel ls --token=${VERCEL_TOKEN} --meta base_hash=${{ env.META_TAG }} &> vercel-output + DEFAULT_URL=$(cat vercel-output | grep http | awk '{print $2}') + ALIAS_URL=$(vercel alias set ${DEFAULT_URL} ${{ steps.set_env.outputs.VERCEL_ALIAS_DOMAIN }} --token=${VERCEL_TOKEN} | awk '{print $3}') + + echo "New preview URL: ${DEFAULT_URL}" + echo "New alias URL: ${ALIAS_URL}" + echo "META_TAG=${META_TAG}" + echo "VERCEL_URL=${ALIAS_URL}" >> "$GITHUB_OUTPUT" + + - uses: mshick/add-pr-comment@v2 + with: + message: | + Your build has completed! + + [Preview deployment](${{ steps.vercel.outputs.VERCEL_URL }}) diff --git a/.github/workflows/remove_deploy_preview.yml b/.github/workflows/remove_deploy_preview.yml new file mode 100644 index 00000000000..924b8dd0746 --- /dev/null +++ b/.github/workflows/remove_deploy_preview.yml @@ -0,0 +1,40 @@ +name: Removedeploypreview + +permissions: + contents: read + statuses: write + pull-requests: write + +env: + VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + +on: + pull_request: + types: + - closed + +jobs: + delete-deployments: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Extract branch name + shell: bash + run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT + id: extract_branch + + - name: Hash branch name + uses: pplanel/hash-calculator-action@v1.3.1 + id: hash_branch + with: + input: ${{ steps.extract_branch.outputs.branch }} + method: MD5 + + - name: Call the delete-deployment-preview.sh script + env: + META_TAG: ${{ steps.hash_branch.outputs.digest }} + run: | + bash ./scripts/delete-deployment-preview.sh From bdc25adb413ffbdbf9a0fa0a944b6778dbe4a0fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E9=AB=98=E7=8C=9B?= Date: Wed, 24 Jan 2024 20:49:30 +0800 Subject: [PATCH 05/23] add delete preview scripts --- scripts/delete-deployment-preview.sh | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 scripts/delete-deployment-preview.sh diff --git a/scripts/delete-deployment-preview.sh b/scripts/delete-deployment-preview.sh new file mode 100755 index 00000000000..fbad29a5d29 --- /dev/null +++ b/scripts/delete-deployment-preview.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Set the pipefail option. +set -o pipefail + +# Get the Vercel API endpoints. +GET_DEPLOYMENTS_ENDPOINT="https://api.vercel.com/v6/deployments" +DELETE_DEPLOYMENTS_ENDPOINT="https://api.vercel.com/v13/deployments" + +# Create a list of deployments. +# deployments=$(curl -s -X GET "$GET_DEPLOYMENTS_ENDPOINT/?projectId=$VERCEL_PROJECT_ID&teamId=$VERCEL_ORG_ID" -H "Authorization: Bearer $VERCEL_TOKEN ") +deployments=$(curl -s -X GET "$GET_DEPLOYMENTS_ENDPOINT/?projectId=$VERCEL_PROJECT_ID" -H "Authorization: Bearer $VERCEL_TOKEN ") + +# Filter the deployments list by meta.base_hash === meta tag. +filtered_deployments=$(echo $deployments | jq --arg META_TAG "$META_TAG" '[.deployments[] | select(.meta.base_hash | type == "string" and contains($META_TAG)) | .uid] | join(",")') +filtered_deployments="${filtered_deployments//\"/}" # Remove double quotes + +# Clears the values from filtered_deployments +IFS=',' read -ra values <<<"$filtered_deployments" + +echo "META_TAG ${META_TAG}" +echo "Filtered deployments ${filtered_deployments}" + +# Iterate over the filtered deployments list. +for uid in "${values[@]}"; do + echo "Deleting ${uid}" + + delete_url=${DELETE_DEPLOYMENTS_ENDPOINT}/${uid} + echo $delete_url + + # Make DELETE a request to the /v13/deployments/{id} endpoint. + curl -X DELETE $delete_url -H "Authorization: Bearer $VERCEL_TOKEN" + + echo "Deleted!" +done From 3bc771a0d9affad24dff4b2babb5f84f90e7a66a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E9=AB=98=E7=8C=9B?= Date: Wed, 24 Jan 2024 22:03:47 +0800 Subject: [PATCH 06/23] add workflow_dispatch --- .github/workflows/deploy_preview.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy_preview.yml b/.github/workflows/deploy_preview.yml index 7bc245ddc3e..98d81bff9f3 100644 --- a/.github/workflows/deploy_preview.yml +++ b/.github/workflows/deploy_preview.yml @@ -1,5 +1,12 @@ name: VercelPreviewDeployment +on: + workflow_dispatch: + inputs: + branchName: + description: 'Branch to deploy' + required: true + env: VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} @@ -11,17 +18,13 @@ permissions: statuses: write pull-requests: write -on: - pull_request: - types: - - opened - - synchronize - jobs: deploy-preview: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + with: + ref: ${{ github.event.inputs.branchName }} - name: Extract branch name shell: bash From 998c95da51eca0c629d3ca6bbb11b1ee1ddaa786 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E9=AB=98=E7=8C=9B?= Date: Wed, 24 Jan 2024 22:10:02 +0800 Subject: [PATCH 07/23] test pr deploy --- .github/workflows/deploy_preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy_preview.yml b/.github/workflows/deploy_preview.yml index 98d81bff9f3..cd0820775ac 100644 --- a/.github/workflows/deploy_preview.yml +++ b/.github/workflows/deploy_preview.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: inputs: branchName: - description: 'Branch to deploy' + description: 'Branch to deploy .' required: true env: From 04fe9fadb11a719e4eaf92748e2a2b70aab1a591 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E9=AB=98=E7=8C=9B?= Date: Wed, 24 Jan 2024 20:19:39 +0800 Subject: [PATCH 08/23] add workflows/deploy preview --- .github/workflows/deploy_preview.yml | 82 +++++++++++++++++++++ .github/workflows/remove_deploy_preview.yml | 40 ++++++++++ 2 files changed, 122 insertions(+) create mode 100644 .github/workflows/deploy_preview.yml create mode 100644 .github/workflows/remove_deploy_preview.yml diff --git a/.github/workflows/deploy_preview.yml b/.github/workflows/deploy_preview.yml new file mode 100644 index 00000000000..7bc245ddc3e --- /dev/null +++ b/.github/workflows/deploy_preview.yml @@ -0,0 +1,82 @@ +name: VercelPreviewDeployment + +env: + VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + VERCEL_DOMAIN_SUFFIX: ".pr.nextchat.dev" + +permissions: + contents: read + statuses: write + pull-requests: write + +on: + pull_request: + types: + - opened + - synchronize + +jobs: + deploy-preview: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Extract branch name + shell: bash + run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> "$GITHUB_OUTPUT" + id: extract_branch + + - name: Hash branch name + uses: pplanel/hash-calculator-action@v1.3.1 + id: hash_branch + with: + input: ${{ steps.extract_branch.outputs.branch }} + method: MD5 + + - name: Set Environment Variables + id: set_env + if: github.event_name == 'pull_request' + run: | + echo "VERCEL_ALIAS_DOMAIN=${{ github.event.pull_request.number }}-${{ github.workflow }}.${VERCEL_DOMAIN_SUFFIX}" >> $GITHUB_OUTPUT + + - name: Install Vercel CLI + run: npm install --global vercel@latest + + - name: Cache dependencies + uses: actions/cache@v2 + id: cache-npm + with: + path: ~/.npm + key: npm-${{ hashFiles('package-lock.json') }} + restore-keys: npm- + + - name: Pull Vercel Environment Information + run: vercel pull --yes --environment=preview --token=${VERCEL_TOKEN} + + - name: Deploy Project Artifacts to Vercel + id: vercel + env: + META_TAG: ${{ steps.hash_branch.outputs.digest }}-${{ github.run_number }}-${{ github.run_attempt}} + run: | + env + vercel pull --yes --environment=preview --token=${VERCEL_TOKEN} + vercel build --token=${VERCEL_TOKEN} + vercel deploy --prebuilt --archive=tgz --token=${VERCEL_TOKEN} --meta base_hash=${{ env.META_TAG }} + + vercel ls --token=${VERCEL_TOKEN} --meta base_hash=${{ env.META_TAG }} &> vercel-output + DEFAULT_URL=$(cat vercel-output | grep http | awk '{print $2}') + ALIAS_URL=$(vercel alias set ${DEFAULT_URL} ${{ steps.set_env.outputs.VERCEL_ALIAS_DOMAIN }} --token=${VERCEL_TOKEN} | awk '{print $3}') + + echo "New preview URL: ${DEFAULT_URL}" + echo "New alias URL: ${ALIAS_URL}" + echo "META_TAG=${META_TAG}" + echo "VERCEL_URL=${ALIAS_URL}" >> "$GITHUB_OUTPUT" + + - uses: mshick/add-pr-comment@v2 + with: + message: | + Your build has completed! + + [Preview deployment](${{ steps.vercel.outputs.VERCEL_URL }}) diff --git a/.github/workflows/remove_deploy_preview.yml b/.github/workflows/remove_deploy_preview.yml new file mode 100644 index 00000000000..924b8dd0746 --- /dev/null +++ b/.github/workflows/remove_deploy_preview.yml @@ -0,0 +1,40 @@ +name: Removedeploypreview + +permissions: + contents: read + statuses: write + pull-requests: write + +env: + VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + +on: + pull_request: + types: + - closed + +jobs: + delete-deployments: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Extract branch name + shell: bash + run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT + id: extract_branch + + - name: Hash branch name + uses: pplanel/hash-calculator-action@v1.3.1 + id: hash_branch + with: + input: ${{ steps.extract_branch.outputs.branch }} + method: MD5 + + - name: Call the delete-deployment-preview.sh script + env: + META_TAG: ${{ steps.hash_branch.outputs.digest }} + run: | + bash ./scripts/delete-deployment-preview.sh From 8fb34465cd1e1fb1a4ef723f6b411814cea5362e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E9=AB=98=E7=8C=9B?= Date: Wed, 24 Jan 2024 20:49:30 +0800 Subject: [PATCH 09/23] add delete preview scripts --- scripts/delete-deployment-preview.sh | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 scripts/delete-deployment-preview.sh diff --git a/scripts/delete-deployment-preview.sh b/scripts/delete-deployment-preview.sh new file mode 100755 index 00000000000..fbad29a5d29 --- /dev/null +++ b/scripts/delete-deployment-preview.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Set the pipefail option. +set -o pipefail + +# Get the Vercel API endpoints. +GET_DEPLOYMENTS_ENDPOINT="https://api.vercel.com/v6/deployments" +DELETE_DEPLOYMENTS_ENDPOINT="https://api.vercel.com/v13/deployments" + +# Create a list of deployments. +# deployments=$(curl -s -X GET "$GET_DEPLOYMENTS_ENDPOINT/?projectId=$VERCEL_PROJECT_ID&teamId=$VERCEL_ORG_ID" -H "Authorization: Bearer $VERCEL_TOKEN ") +deployments=$(curl -s -X GET "$GET_DEPLOYMENTS_ENDPOINT/?projectId=$VERCEL_PROJECT_ID" -H "Authorization: Bearer $VERCEL_TOKEN ") + +# Filter the deployments list by meta.base_hash === meta tag. +filtered_deployments=$(echo $deployments | jq --arg META_TAG "$META_TAG" '[.deployments[] | select(.meta.base_hash | type == "string" and contains($META_TAG)) | .uid] | join(",")') +filtered_deployments="${filtered_deployments//\"/}" # Remove double quotes + +# Clears the values from filtered_deployments +IFS=',' read -ra values <<<"$filtered_deployments" + +echo "META_TAG ${META_TAG}" +echo "Filtered deployments ${filtered_deployments}" + +# Iterate over the filtered deployments list. +for uid in "${values[@]}"; do + echo "Deleting ${uid}" + + delete_url=${DELETE_DEPLOYMENTS_ENDPOINT}/${uid} + echo $delete_url + + # Make DELETE a request to the /v13/deployments/{id} endpoint. + curl -X DELETE $delete_url -H "Authorization: Bearer $VERCEL_TOKEN" + + echo "Deleted!" +done From 0739ced4072276e6d3e89e7ea275db04eb566290 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E9=AB=98=E7=8C=9B?= Date: Wed, 24 Jan 2024 22:03:47 +0800 Subject: [PATCH 10/23] add workflow_dispatch --- .github/workflows/deploy_preview.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy_preview.yml b/.github/workflows/deploy_preview.yml index 7bc245ddc3e..98d81bff9f3 100644 --- a/.github/workflows/deploy_preview.yml +++ b/.github/workflows/deploy_preview.yml @@ -1,5 +1,12 @@ name: VercelPreviewDeployment +on: + workflow_dispatch: + inputs: + branchName: + description: 'Branch to deploy' + required: true + env: VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} @@ -11,17 +18,13 @@ permissions: statuses: write pull-requests: write -on: - pull_request: - types: - - opened - - synchronize - jobs: deploy-preview: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + with: + ref: ${{ github.event.inputs.branchName }} - name: Extract branch name shell: bash From 2f11e7c08764855ffdddc3aa0b8f85ad99e904af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E9=AB=98=E7=8C=9B?= Date: Thu, 25 Jan 2024 11:04:32 +0800 Subject: [PATCH 11/23] test pr deploy --- .github/workflows/deploy_preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy_preview.yml b/.github/workflows/deploy_preview.yml index cd0820775ac..98d81bff9f3 100644 --- a/.github/workflows/deploy_preview.yml +++ b/.github/workflows/deploy_preview.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: inputs: branchName: - description: 'Branch to deploy .' + description: 'Branch to deploy' required: true env: From 94f534f36f8eee1ae336aa4764e00f02ae4d94b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E9=AB=98=E7=8C=9B?= Date: Thu, 25 Jan 2024 14:33:38 +0800 Subject: [PATCH 12/23] fix vercel alias domains --- .github/workflows/deploy_preview.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy_preview.yml b/.github/workflows/deploy_preview.yml index 98d81bff9f3..9079ddd4b5c 100644 --- a/.github/workflows/deploy_preview.yml +++ b/.github/workflows/deploy_preview.yml @@ -8,6 +8,7 @@ on: required: true env: + VERCEL_TEAM: ${{ secrets.VERCEL_TEAM }} VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} @@ -63,14 +64,13 @@ jobs: env: META_TAG: ${{ steps.hash_branch.outputs.digest }}-${{ github.run_number }}-${{ github.run_attempt}} run: | - env vercel pull --yes --environment=preview --token=${VERCEL_TOKEN} vercel build --token=${VERCEL_TOKEN} vercel deploy --prebuilt --archive=tgz --token=${VERCEL_TOKEN} --meta base_hash=${{ env.META_TAG }} vercel ls --token=${VERCEL_TOKEN} --meta base_hash=${{ env.META_TAG }} &> vercel-output DEFAULT_URL=$(cat vercel-output | grep http | awk '{print $2}') - ALIAS_URL=$(vercel alias set ${DEFAULT_URL} ${{ steps.set_env.outputs.VERCEL_ALIAS_DOMAIN }} --token=${VERCEL_TOKEN} | awk '{print $3}') + ALIAS_URL=$(vercel alias set ${DEFAULT_URL} ${{ steps.set_env.outputs.VERCEL_ALIAS_DOMAIN }} --token=${VERCEL_TOKEN} --scope ${VERCEL_TEAM}| awk '{print $3}') echo "New preview URL: ${DEFAULT_URL}" echo "New alias URL: ${ALIAS_URL}" From 6206ceb49b26b987adcde5e0715cc83adf500e21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E9=AB=98=E7=8C=9B?= Date: Thu, 25 Jan 2024 15:00:44 +0800 Subject: [PATCH 13/23] fix: cicd , add pull_request_target --- .github/workflows/deploy_preview.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy_preview.yml b/.github/workflows/deploy_preview.yml index 9079ddd4b5c..fc2969b7a1e 100644 --- a/.github/workflows/deploy_preview.yml +++ b/.github/workflows/deploy_preview.yml @@ -1,11 +1,11 @@ name: VercelPreviewDeployment on: + pull_request_target: + types: + - opened + - synchronize workflow_dispatch: - inputs: - branchName: - description: 'Branch to deploy' - required: true env: VERCEL_TEAM: ${{ secrets.VERCEL_TEAM }} From 43631a32718bfa287dfcb10e95087b0ef5a2d3ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E9=AB=98=E7=8C=9B?= Date: Thu, 25 Jan 2024 15:17:03 +0800 Subject: [PATCH 14/23] fix: cicd, vercel domain suffix secret --- .github/workflows/deploy_preview.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy_preview.yml b/.github/workflows/deploy_preview.yml index fc2969b7a1e..f392e3de996 100644 --- a/.github/workflows/deploy_preview.yml +++ b/.github/workflows/deploy_preview.yml @@ -12,7 +12,7 @@ env: VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} - VERCEL_DOMAIN_SUFFIX: ".pr.nextchat.dev" + VERCEL_PR_DOMAIN_SUFFIX: ${{ secrets.VERCEL_PR_DOMAIN_SUFFIX }} permissions: contents: read @@ -43,7 +43,7 @@ jobs: id: set_env if: github.event_name == 'pull_request' run: | - echo "VERCEL_ALIAS_DOMAIN=${{ github.event.pull_request.number }}-${{ github.workflow }}.${VERCEL_DOMAIN_SUFFIX}" >> $GITHUB_OUTPUT + echo "VERCEL_ALIAS_DOMAIN=${{ github.event.pull_request.number }}-${{ github.workflow }}.${VERCEL_PR_DOMAIN_SUFFIX}" >> $GITHUB_OUTPUT - name: Install Vercel CLI run: npm install --global vercel@latest From f619e9df241f3cb4dc47b251c8a37537e51be2db Mon Sep 17 00:00:00 2001 From: fred-bf <157469842+fred-bf@users.noreply.github.com> Date: Thu, 25 Jan 2024 15:17:16 +0800 Subject: [PATCH 15/23] chore: change default submit key --- app/store/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/store/config.ts b/app/store/config.ts index 057e31b2565..20bf664df56 100644 --- a/app/store/config.ts +++ b/app/store/config.ts @@ -28,7 +28,7 @@ export enum Theme { export const DEFAULT_CONFIG = { lastUpdate: Date.now(), // timestamp, to merge state - submitKey: isMacOS() ? SubmitKey.MetaEnter : SubmitKey.CtrlEnter, + submitKey: SubmitKey.Enter, avatar: "1f603", fontSize: 14, theme: Theme.Auto as Theme, From fae82a30e7b127427199cfe2b2fc2a1f095a2414 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E9=AB=98=E7=8C=9B?= Date: Thu, 25 Jan 2024 16:53:03 +0800 Subject: [PATCH 16/23] fix: cicd, delete vercel pre --- scripts/delete-deployment-preview.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/delete-deployment-preview.sh b/scripts/delete-deployment-preview.sh index fbad29a5d29..4f2bb34957d 100755 --- a/scripts/delete-deployment-preview.sh +++ b/scripts/delete-deployment-preview.sh @@ -7,11 +7,11 @@ GET_DEPLOYMENTS_ENDPOINT="https://api.vercel.com/v6/deployments" DELETE_DEPLOYMENTS_ENDPOINT="https://api.vercel.com/v13/deployments" # Create a list of deployments. -# deployments=$(curl -s -X GET "$GET_DEPLOYMENTS_ENDPOINT/?projectId=$VERCEL_PROJECT_ID&teamId=$VERCEL_ORG_ID" -H "Authorization: Bearer $VERCEL_TOKEN ") -deployments=$(curl -s -X GET "$GET_DEPLOYMENTS_ENDPOINT/?projectId=$VERCEL_PROJECT_ID" -H "Authorization: Bearer $VERCEL_TOKEN ") +deployments=$(curl -s -X GET "$GET_DEPLOYMENTS_ENDPOINT/?projectId=$VERCEL_PROJECT_ID&teamId=$VERCEL_ORG_ID" -H "Authorization: Bearer $VERCEL_TOKEN ") +#deployments=$(curl -s -X GET "$GET_DEPLOYMENTS_ENDPOINT/?projectId=$VERCEL_PROJECT_ID" -H "Authorization: Bearer $VERCEL_TOKEN ") # Filter the deployments list by meta.base_hash === meta tag. -filtered_deployments=$(echo $deployments | jq --arg META_TAG "$META_TAG" '[.deployments[] | select(.meta.base_hash | type == "string" and contains($META_TAG)) | .uid] | join(",")') +filtered_deployments=$(echo -E $deployments | jq --arg META_TAG "$META_TAG" '[.deployments[] | select(.meta.base_hash | type == "string" and contains($META_TAG)) | .uid] | join(",")') filtered_deployments="${filtered_deployments//\"/}" # Remove double quotes # Clears the values from filtered_deployments @@ -24,7 +24,7 @@ echo "Filtered deployments ${filtered_deployments}" for uid in "${values[@]}"; do echo "Deleting ${uid}" - delete_url=${DELETE_DEPLOYMENTS_ENDPOINT}/${uid} + delete_url="${DELETE_DEPLOYMENTS_ENDPOINT}/${uid}?teamId=${VERCEL_ORG_ID}" echo $delete_url # Make DELETE a request to the /v13/deployments/{id} endpoint. From ba3e7e79741289c9eddee533828aa40c1e9e940a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E9=AB=98=E7=8C=9B?= Date: Thu, 25 Jan 2024 19:31:17 +0800 Subject: [PATCH 17/23] fix: cicd, vercel alias domain --- .github/workflows/deploy_preview.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy_preview.yml b/.github/workflows/deploy_preview.yml index 2524990d812..387585f469f 100644 --- a/.github/workflows/deploy_preview.yml +++ b/.github/workflows/deploy_preview.yml @@ -64,17 +64,17 @@ jobs: env: META_TAG: ${{ steps.hash_branch.outputs.digest }}-${{ github.run_number }}-${{ github.run_attempt}} run: | + set -e vercel pull --yes --environment=preview --token=${VERCEL_TOKEN} vercel build --token=${VERCEL_TOKEN} vercel deploy --prebuilt --archive=tgz --token=${VERCEL_TOKEN} --meta base_hash=${{ env.META_TAG }} - vercel ls --token=${VERCEL_TOKEN} --meta base_hash=${{ env.META_TAG }} &> vercel-output - DEFAULT_URL=$(cat vercel-output | grep http | awk '{print $2}') + DEFAULT_URL=$(vercel ls --token=${VERCEL_TOKEN} --meta base_hash=${{ env.META_TAG }}) + echo "preview URL:${DEFAULT_URL} , alias URL:${{ steps.set_env.outputs.VERCEL_ALIAS_DOMAIN }}" ALIAS_URL=$(vercel alias set ${DEFAULT_URL} ${{ steps.set_env.outputs.VERCEL_ALIAS_DOMAIN }} --token=${VERCEL_TOKEN} --scope ${VERCEL_TEAM}| awk '{print $3}') echo "New preview URL: ${DEFAULT_URL}" echo "New alias URL: ${ALIAS_URL}" - echo "META_TAG=${META_TAG}" echo "VERCEL_URL=${ALIAS_URL}" >> "$GITHUB_OUTPUT" - uses: mshick/add-pr-comment@v2 @@ -82,4 +82,4 @@ jobs: message: | Your build has completed! - [Preview deployment](${{ steps.vercel.outputs.VERCEL_URL }}) \ No newline at end of file + [Preview deployment](${{ steps.vercel.outputs.VERCEL_URL }}) From 32bcdb8982bfe12b9f26b3f8414a88ead7ca943e Mon Sep 17 00:00:00 2001 From: sungaomeng <18810164094@163.com> Date: Thu, 25 Jan 2024 19:37:29 +0800 Subject: [PATCH 18/23] fix: cicd, delete vercel pre (#3910) --- .github/workflows/deploy_preview.yml | 8 ++++---- scripts/delete-deployment-preview.sh | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/deploy_preview.yml b/.github/workflows/deploy_preview.yml index 2524990d812..387585f469f 100644 --- a/.github/workflows/deploy_preview.yml +++ b/.github/workflows/deploy_preview.yml @@ -64,17 +64,17 @@ jobs: env: META_TAG: ${{ steps.hash_branch.outputs.digest }}-${{ github.run_number }}-${{ github.run_attempt}} run: | + set -e vercel pull --yes --environment=preview --token=${VERCEL_TOKEN} vercel build --token=${VERCEL_TOKEN} vercel deploy --prebuilt --archive=tgz --token=${VERCEL_TOKEN} --meta base_hash=${{ env.META_TAG }} - vercel ls --token=${VERCEL_TOKEN} --meta base_hash=${{ env.META_TAG }} &> vercel-output - DEFAULT_URL=$(cat vercel-output | grep http | awk '{print $2}') + DEFAULT_URL=$(vercel ls --token=${VERCEL_TOKEN} --meta base_hash=${{ env.META_TAG }}) + echo "preview URL:${DEFAULT_URL} , alias URL:${{ steps.set_env.outputs.VERCEL_ALIAS_DOMAIN }}" ALIAS_URL=$(vercel alias set ${DEFAULT_URL} ${{ steps.set_env.outputs.VERCEL_ALIAS_DOMAIN }} --token=${VERCEL_TOKEN} --scope ${VERCEL_TEAM}| awk '{print $3}') echo "New preview URL: ${DEFAULT_URL}" echo "New alias URL: ${ALIAS_URL}" - echo "META_TAG=${META_TAG}" echo "VERCEL_URL=${ALIAS_URL}" >> "$GITHUB_OUTPUT" - uses: mshick/add-pr-comment@v2 @@ -82,4 +82,4 @@ jobs: message: | Your build has completed! - [Preview deployment](${{ steps.vercel.outputs.VERCEL_URL }}) \ No newline at end of file + [Preview deployment](${{ steps.vercel.outputs.VERCEL_URL }}) diff --git a/scripts/delete-deployment-preview.sh b/scripts/delete-deployment-preview.sh index fbad29a5d29..4f2bb34957d 100755 --- a/scripts/delete-deployment-preview.sh +++ b/scripts/delete-deployment-preview.sh @@ -7,11 +7,11 @@ GET_DEPLOYMENTS_ENDPOINT="https://api.vercel.com/v6/deployments" DELETE_DEPLOYMENTS_ENDPOINT="https://api.vercel.com/v13/deployments" # Create a list of deployments. -# deployments=$(curl -s -X GET "$GET_DEPLOYMENTS_ENDPOINT/?projectId=$VERCEL_PROJECT_ID&teamId=$VERCEL_ORG_ID" -H "Authorization: Bearer $VERCEL_TOKEN ") -deployments=$(curl -s -X GET "$GET_DEPLOYMENTS_ENDPOINT/?projectId=$VERCEL_PROJECT_ID" -H "Authorization: Bearer $VERCEL_TOKEN ") +deployments=$(curl -s -X GET "$GET_DEPLOYMENTS_ENDPOINT/?projectId=$VERCEL_PROJECT_ID&teamId=$VERCEL_ORG_ID" -H "Authorization: Bearer $VERCEL_TOKEN ") +#deployments=$(curl -s -X GET "$GET_DEPLOYMENTS_ENDPOINT/?projectId=$VERCEL_PROJECT_ID" -H "Authorization: Bearer $VERCEL_TOKEN ") # Filter the deployments list by meta.base_hash === meta tag. -filtered_deployments=$(echo $deployments | jq --arg META_TAG "$META_TAG" '[.deployments[] | select(.meta.base_hash | type == "string" and contains($META_TAG)) | .uid] | join(",")') +filtered_deployments=$(echo -E $deployments | jq --arg META_TAG "$META_TAG" '[.deployments[] | select(.meta.base_hash | type == "string" and contains($META_TAG)) | .uid] | join(",")') filtered_deployments="${filtered_deployments//\"/}" # Remove double quotes # Clears the values from filtered_deployments @@ -24,7 +24,7 @@ echo "Filtered deployments ${filtered_deployments}" for uid in "${values[@]}"; do echo "Deleting ${uid}" - delete_url=${DELETE_DEPLOYMENTS_ENDPOINT}/${uid} + delete_url="${DELETE_DEPLOYMENTS_ENDPOINT}/${uid}?teamId=${VERCEL_ORG_ID}" echo $delete_url # Make DELETE a request to the /v13/deployments/{id} endpoint. From 15d25df2458ff9160eff5184158aea3bfa6571d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E9=AB=98=E7=8C=9B?= Date: Thu, 25 Jan 2024 19:43:26 +0800 Subject: [PATCH 19/23] fix: cicd, delete velcel pre --- .github/workflows/remove_deploy_preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/remove_deploy_preview.yml b/.github/workflows/remove_deploy_preview.yml index 924b8dd0746..4846cda2d6a 100644 --- a/.github/workflows/remove_deploy_preview.yml +++ b/.github/workflows/remove_deploy_preview.yml @@ -11,7 +11,7 @@ env: VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} on: - pull_request: + pull_request_target: types: - closed From ecbab75a25a347f8990db7e902cb900cb7ebb990 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E9=AB=98=E7=8C=9B?= Date: Thu, 25 Jan 2024 19:54:58 +0800 Subject: [PATCH 20/23] fix: cicd, alias domain env name --- .github/workflows/deploy_preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy_preview.yml b/.github/workflows/deploy_preview.yml index 387585f469f..a62a5fc205a 100644 --- a/.github/workflows/deploy_preview.yml +++ b/.github/workflows/deploy_preview.yml @@ -41,7 +41,7 @@ jobs: - name: Set Environment Variables id: set_env - if: github.event_name == 'pull_request' + if: github.event_name == 'pull_request_target' run: | echo "VERCEL_ALIAS_DOMAIN=${{ github.event.pull_request.number }}-${{ github.workflow }}.${VERCEL_PR_DOMAIN_SUFFIX}" >> $GITHUB_OUTPUT From 148c32a38383dcd4bd8927a75eb97105fab23806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E9=AB=98=E7=8C=9B?= Date: Thu, 25 Jan 2024 20:46:42 +0800 Subject: [PATCH 21/23] fix: cicd, remove workflow_dispatch --- .github/workflows/deploy_preview.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/deploy_preview.yml b/.github/workflows/deploy_preview.yml index a62a5fc205a..5470c2d21bd 100644 --- a/.github/workflows/deploy_preview.yml +++ b/.github/workflows/deploy_preview.yml @@ -5,7 +5,6 @@ on: types: - opened - synchronize - workflow_dispatch: env: VERCEL_TEAM: ${{ secrets.VERCEL_TEAM }} @@ -24,8 +23,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - with: - ref: ${{ github.event.inputs.branchName }} - name: Extract branch name shell: bash @@ -70,7 +67,6 @@ jobs: vercel deploy --prebuilt --archive=tgz --token=${VERCEL_TOKEN} --meta base_hash=${{ env.META_TAG }} DEFAULT_URL=$(vercel ls --token=${VERCEL_TOKEN} --meta base_hash=${{ env.META_TAG }}) - echo "preview URL:${DEFAULT_URL} , alias URL:${{ steps.set_env.outputs.VERCEL_ALIAS_DOMAIN }}" ALIAS_URL=$(vercel alias set ${DEFAULT_URL} ${{ steps.set_env.outputs.VERCEL_ALIAS_DOMAIN }} --token=${VERCEL_TOKEN} --scope ${VERCEL_TEAM}| awk '{print $3}') echo "New preview URL: ${DEFAULT_URL}" From 3fa55f9022b20fb3b31d14d82cc712d6fa470449 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E9=AB=98=E7=8C=9B?= Date: Thu, 25 Jan 2024 21:17:10 +0800 Subject: [PATCH 22/23] fix: cicd, checkout sha --- .github/workflows/deploy_preview.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/deploy_preview.yml b/.github/workflows/deploy_preview.yml index 5470c2d21bd..02ee0f1923d 100644 --- a/.github/workflows/deploy_preview.yml +++ b/.github/workflows/deploy_preview.yml @@ -23,6 +23,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.sha }} - name: Extract branch name shell: bash From 981a3629b6eeb9f41090c2a7cd4fd568f6981a55 Mon Sep 17 00:00:00 2001 From: Leo Li Date: Fri, 26 Jan 2024 02:00:02 -0500 Subject: [PATCH 23/23] Add gpt-4-0125-preview (#3924) --- app/constant.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/constant.ts b/app/constant.ts index 53d47540ac6..af64c92dc9c 100644 --- a/app/constant.ts +++ b/app/constant.ts @@ -108,6 +108,7 @@ export const SUMMARIZE_MODEL = "gpt-3.5-turbo"; export const KnowledgeCutOffDate: Record = { default: "2021-09", "gpt-4-1106-preview": "2023-04", + "gpt-4-0125-preview": "2023-04", "gpt-4-vision-preview": "2023-04", }; @@ -175,6 +176,15 @@ export const DEFAULT_MODELS = [ providerType: "openai", }, }, + { + name: "gpt-4-0125-preview", + available: true, + provider: { + id: "openai", + providerName: "OpenAI", + providerType: "openai", + }, + }, { name: "gpt-4-vision-preview", available: true,