Skip to content

Commit 5942918

Browse files
authoredSep 17, 2024··
fix(ci): Add script for aliasing domains in gh deployments (#6838)
1 parent ef2df67 commit 5942918

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed
 

‎.github/scripts/deployDomainVercel.sh

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
# Check if an argument is provided
4+
if [ $# -eq 0 ]; then
5+
echo "Error: Please provide a version string as an argument."
6+
exit 1
7+
fi
8+
9+
inputString=$1
10+
11+
# Check if VERCEL_TOKEN is set
12+
if [ -z "$VERCEL_TOKEN" ]; then
13+
echo "Error: VERCEL_TOKEN is not set."
14+
exit 1
15+
fi
16+
17+
# save stdout and stderr to files
18+
vercel deploy --prebuilt --token="$VERCEL_TOKEN" >deployment-url.txt 2>error.txt
19+
20+
# check the exit code
21+
code=$?
22+
if [ $code -eq 0 ]; then
23+
# Set the deploymentUrl using the input string
24+
deploymentUrl="${inputString}.api.js.langchain.com"
25+
vercel alias $(cat deployment-url.txt) $deploymentUrl --token="$VERCEL_TOKEN" --scope="langchain"
26+
else
27+
# Handle the error
28+
errorMessage=$(cat error.txt)
29+
echo "There was an error: $errorMessage"
30+
fi

‎.github/workflows/deploy-api-refs-prod.yml

+17-2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,21 @@ jobs:
3434
- name: Build All Projects
3535
run: yarn turbo:command build --filter=!examples --filter=!api_refs --filter=!core_docs --filter=!create-langchain-integration
3636
- name: Build Project Artifacts
37-
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
37+
run: |
38+
if [ ${{ github.ref }} = 'refs/heads/main' ]; then
39+
vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
40+
else
41+
vercel build --token=${{ secrets.VERCEL_TOKEN }}
42+
fi
3843
- name: Deploy to Vercel
39-
run: vercel deploy --prod --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
44+
env:
45+
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
46+
run: |
47+
if [ ${{ github.ref }} = 'refs/heads/main' ]; then
48+
vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
49+
elif [ ${{ github.ref }} = 'refs/heads/v0.2' ]; then
50+
.github/scripts/deployDomainVercel.sh v02
51+
else
52+
echo "Error: Deployment is only allowed for 'main' or 'v0.2' branches."
53+
exit 1
54+
fi

0 commit comments

Comments
 (0)
Please sign in to comment.