Build, Push, and Deploy Chat Langchain #91
Workflow file for this run
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
name: Build, Push, and Deploy Chat Langchain | |
on: | |
push: | |
branches: [master] | |
workflow_dispatch: | |
env: | |
POETRY_VERSION: "1.7.1" | |
PYTHON_VERSION: "3.11" | |
jobs: | |
deploy-backend: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Short Hash | |
run: | | |
echo "GIT_SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
echo "LC_ENVIRONMENT=dev" >> $GITHUB_ENV | |
- name: Set up Python ${{ env.PYTHON_VERSION }} + Poetry ${{ env.POETRY_VERSION }} | |
uses: "./.github/actions/poetry_setup" | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
poetry-version: ${{ env.POETRY_VERSION }} | |
cache-key: lint | |
- name: Set up depot.dev multi-arch runner | |
uses: depot/setup-action@v1 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push | |
run: | | |
pip install langgraph-cli | |
langgraph build -t docker.io/langchain/chat-langchain-backend:${{ env.GIT_SHORT_SHA }} | |
docker push docker.io/langchain/chat-langchain-backend:${{ env.GIT_SHORT_SHA }} | |
- name: Checkout deployments repo | |
uses: actions/checkout@v3 | |
with: | |
repository: langchain-ai/deployments | |
path: deployments | |
token: ${{ secrets.DEPLOYMENTS_PAT }} | |
- name: Update Docker image in Terraform files (dev) | |
run: | | |
cd deployments/environments/gcp/chat-langchain | |
# Modify the main.tf terraform file | |
sed -i "s|image_tag = \"docker.io/langchain/chat-langchain-backend:[^\"]*\"|image_tag = \"docker.io/langchain/chat-langchain-backend:${{ env.GIT_SHORT_SHA }}\"|" main.tf | |
- name: Create Pull Request | |
id: create-pr | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
token: ${{ secrets.DEPLOYMENTS_PAT }} | |
title: "Update Chat Langchain Docker image to ${{ env.GIT_SHORT_SHA }}" | |
commit-message: "Update Docker image" | |
base: "main" | |
branch: "actions/update-docker-image-${{ env.GIT_SHORT_SHA }}" | |
body: 'Update Chat Langchain Docker image to ${{ env.GIT_SHORT_SHA }}' | |
path: deployments | |
- name: Enable Pull Request Automerge | |
uses: peter-evans/enable-pull-request-automerge@v3 | |
with: | |
token: ${{ secrets.DEPLOYMENTS_PAT }} | |
pull-request-number: ${{ steps.create-pr.outputs.pull-request-number }} | |
repository: langchain-ai/deployments | |
deploy-frontend: | |
name: Deploy Frontend to Vercel | |
runs-on: ubuntu-latest | |
environment: Production | |
needs: deploy-backend | |
env: | |
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | |
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} | |
steps: | |
- uses: actions/checkout@v2 | |
- 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 }} |