mirror of
https://github.com/open-webui/open-webui
synced 2025-04-18 21:38:28 +00:00
148 lines
4.4 KiB
YAML
148 lines
4.4 KiB
YAML
name: Build and Push Docker Image
|
|
|
|
on:
|
|
push:
|
|
branches: [ "main", "staging" ]
|
|
pull_request:
|
|
branches: [ "main", "staging" ]
|
|
|
|
env:
|
|
REGISTRY: ghcr.io
|
|
IMAGE_NAME: ${{ github.repository }}
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Log in to the Container registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Extract metadata (tags, labels) for Docker
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
tags: |
|
|
type=sha,format=long
|
|
type=ref,event=branch
|
|
type=ref,event=tag
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
build-args: |
|
|
LITELLM_BASE_URL=/litellm
|
|
|
|
deploy-production:
|
|
needs: build-and-push
|
|
runs-on: ubuntu-latest
|
|
if: github.ref == 'refs/heads/main'
|
|
environment: production
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Create directory on EC2 if it doesn't exist
|
|
uses: appleboy/ssh-action@v1.0.3
|
|
with:
|
|
host: ${{ secrets.PROD_EC2_HOST }}
|
|
username: ${{ secrets.PROD_EC2_USERNAME }}
|
|
key: ${{ secrets.PROD_EC2_SSH_KEY }}
|
|
script: mkdir -p ~/beyond-the-loop
|
|
|
|
- name: Copy docker-compose file to EC2
|
|
uses: appleboy/scp-action@v0.1.7
|
|
with:
|
|
host: ${{ secrets.PROD_EC2_HOST }}
|
|
username: ${{ secrets.PROD_EC2_USERNAME }}
|
|
key: ${{ secrets.PROD_EC2_SSH_KEY }}
|
|
source: "docker-compose-prod.yaml"
|
|
target: "~/beyond-the-loop/docker-compose.yaml"
|
|
overwrite: true
|
|
|
|
- name: Copy litellm-config file to EC2
|
|
uses: appleboy/scp-action@v0.1.7
|
|
with:
|
|
host: ${{ secrets.PROD_EC2_HOST }}
|
|
username: ${{ secrets.PROD_EC2_USERNAME }}
|
|
key: ${{ secrets.PROD_EC2_SSH_KEY }}
|
|
source: "litellm-config.yaml"
|
|
target: "~/beyond-the-loop"
|
|
overwrite: true
|
|
|
|
- name: Deploy to EC2
|
|
uses: appleboy/ssh-action@v1.0.3
|
|
with:
|
|
host: ${{ secrets.PROD_EC2_HOST }}
|
|
username: ${{ secrets.PROD_EC2_USERNAME }}
|
|
key: ${{ secrets.PROD_EC2_SSH_KEY }}
|
|
script: |
|
|
cd ~/beyond-the-loop
|
|
docker-compose pull
|
|
docker-compose up -d
|
|
|
|
deploy-staging:
|
|
needs: build-and-push
|
|
runs-on: ubuntu-latest
|
|
if: github.ref == 'refs/heads/staging'
|
|
environment: staging
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Create directory on EC2 if it doesn't exist
|
|
uses: appleboy/ssh-action@v1.0.3
|
|
with:
|
|
host: ${{ secrets.STAGING_EC2_HOST }}
|
|
username: ${{ secrets.STAGING_EC2_USERNAME }}
|
|
key: ${{ secrets.STAGING_EC2_SSH_KEY }}
|
|
script: mkdir -p ~/beyond-the-loop
|
|
|
|
- name: Copy docker-compose file to EC2
|
|
uses: appleboy/scp-action@v0.1.7
|
|
with:
|
|
host: ${{ secrets.STAGING_EC2_HOST }}
|
|
username: ${{ secrets.STAGING_EC2_USERNAME }}
|
|
key: ${{ secrets.STAGING_EC2_SSH_KEY }}
|
|
source: "docker-compose-staging.yaml"
|
|
target: "~/beyond-the-loop/docker-compose.yaml"
|
|
overwrite: true
|
|
|
|
- name: Copy litellm-config file to EC2
|
|
uses: appleboy/scp-action@v0.1.7
|
|
with:
|
|
host: ${{ secrets.STAGING_EC2_HOST }}
|
|
username: ${{ secrets.STAGING_EC2_USERNAME }}
|
|
key: ${{ secrets.STAGING_EC2_SSH_KEY }}
|
|
source: "litellm-config.yaml"
|
|
target: "~/beyond-the-loop"
|
|
overwrite: true
|
|
|
|
- name: Deploy to EC2
|
|
uses: appleboy/ssh-action@v1.0.3
|
|
with:
|
|
host: ${{ secrets.STAGING_EC2_HOST }}
|
|
username: ${{ secrets.STAGING_EC2_USERNAME }}
|
|
key: ${{ secrets.STAGING_EC2_SSH_KEY }}
|
|
script: |
|
|
cd ~/beyond-the-loop
|
|
docker-compose pull
|
|
docker-compose up -d
|