-
Notifications
You must be signed in to change notification settings - Fork 60.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'ChatGPTNextWeb:main' into patch-prompt
- Loading branch information
Showing
10 changed files
with
190 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
name: VercelPreviewDeployment | ||
|
||
on: | ||
pull_request_target: | ||
types: | ||
- opened | ||
- synchronize | ||
|
||
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 }} | ||
VERCEL_PR_DOMAIN_SUFFIX: ${{ secrets.VERCEL_PR_DOMAIN_SUFFIX }} | ||
|
||
permissions: | ||
contents: read | ||
statuses: write | ||
pull-requests: write | ||
|
||
jobs: | ||
deploy-preview: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
|
||
- 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/[email protected] | ||
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_target' | ||
run: | | ||
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 | ||
|
||
- 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: | | ||
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 }} | ||
DEFAULT_URL=$(vercel ls --token=${VERCEL_TOKEN} --meta base_hash=${{ env.META_TAG }}) | ||
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 "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 }}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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_target: | ||
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/[email protected] | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 -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 | ||
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}?teamId=${VERCEL_ORG_ID}" | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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/[email protected]": | ||
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== | ||
|
||
[email protected]: | ||
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" | ||
|