Skip to content

Commit

Permalink
fix(ci): Add script for aliasing domains in gh deployments (langchain…
Browse files Browse the repository at this point in the history
  • Loading branch information
bracesproul authored and FilipZmijewski committed Sep 27, 2024
1 parent d1230ff commit 92938a6
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
30 changes: 30 additions & 0 deletions .github/scripts/deployDomainVercel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

# Check if an argument is provided
if [ $# -eq 0 ]; then
echo "Error: Please provide a version string as an argument."
exit 1
fi

inputString=$1

# Check if VERCEL_TOKEN is set
if [ -z "$VERCEL_TOKEN" ]; then
echo "Error: VERCEL_TOKEN is not set."
exit 1
fi

# save stdout and stderr to files
vercel deploy --prebuilt --token="$VERCEL_TOKEN" >deployment-url.txt 2>error.txt

# check the exit code
code=$?
if [ $code -eq 0 ]; then
# Set the deploymentUrl using the input string
deploymentUrl="${inputString}.api.js.langchain.com"
vercel alias $(cat deployment-url.txt) $deploymentUrl --token="$VERCEL_TOKEN" --scope="langchain"
else
# Handle the error
errorMessage=$(cat error.txt)
echo "There was an error: $errorMessage"
fi
19 changes: 17 additions & 2 deletions .github/workflows/deploy-api-refs-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ jobs:
- name: Build All Projects
run: yarn turbo:command build --filter=!examples --filter=!api_refs --filter=!core_docs --filter=!create-langchain-integration
- name: Build Project Artifacts
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
run: |
if [ ${{ github.ref }} = 'refs/heads/main' ]; then
vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
else
vercel build --token=${{ secrets.VERCEL_TOKEN }}
fi
- name: Deploy to Vercel
run: vercel deploy --prod --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
run: |
if [ ${{ github.ref }} = 'refs/heads/main' ]; then
vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
elif [ ${{ github.ref }} = 'refs/heads/v0.2' ]; then
.github/scripts/deployDomainVercel.sh v02
else
echo "Error: Deployment is only allowed for 'main' or 'v0.2' branches."
exit 1
fi

0 comments on commit 92938a6

Please sign in to comment.