Add GitHub Action for automated backend deployment
- Build and push Docker image on PR merge or manual trigger - Deploy to production server via SSH - Uses Makefile for consistent build process 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>pull/21891/head
parent
0d5949ba46
commit
03155f658d
@ -0,0 +1,55 @@
|
|||||||
|
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
|
||||||
Loading…
Reference in New Issue