You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.5 KiB
YAML
55 lines
1.5 KiB
YAML
name: Deploy Backend API
|
|
|
|
on:
|
|
pull_request:
|
|
types: [closed]
|
|
branches:
|
|
- main
|
|
- master
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build-and-push:
|
|
# Only run if PR was merged or manually triggered
|
|
if: github.event_name == 'workflow_dispatch' || (github.event.pull_request.merged == true)
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Build and push API image using Makefile
|
|
run: |
|
|
make build-push-api
|
|
|
|
deploy:
|
|
needs: build-and-push
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Deploy to Production Server
|
|
uses: appleboy/ssh-action@v1.0.3
|
|
with:
|
|
host: qingsu.chat
|
|
username: root
|
|
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
port: 22
|
|
script: |
|
|
cd /root/projects/jim-dify
|
|
git fetch origin
|
|
git reset --hard origin/$(git branch --show-current)
|
|
cd docker
|
|
export HTTP_PROXY=http://host.docker.internal:1081
|
|
export HTTPS_PROXY=http://host.docker.internal:1081
|
|
export NO_PROXY=weaviate,sandbox,plugin_daemon,localhost,127.0.0.1
|
|
docker compose pull
|
|
docker compose up -d --force-recreate nginx web api worker scheduler |