feat: Add Gitea Actions workflows and setup documentation for deployment

This commit is contained in:
ethan.chen
2026-01-07 14:06:12 +08:00
parent 6ab690fa40
commit 459f99e804
5 changed files with 361 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
name: Deploy to Server (Simple)
on:
push:
branches:
- main
- master
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Deploy to server via SSH
env:
SSH_KEY: ${{ secrets.SERVER_SSH_KEY }}
SSH_USER: ${{ secrets.SERVER_USERNAME }}
SSH_HOST: ${{ secrets.SERVER_HOST }}
run: |
# Setup SSH
mkdir -p ~/.ssh
echo "$SSH_KEY" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
# Add host to known_hosts (optional, for security)
ssh-keyscan -H "$SSH_HOST" >> ~/.ssh/known_hosts 2>/dev/null || true
# Deploy
ssh -i ~/.ssh/deploy_key \
-o StrictHostKeyChecking=no \
-o UserKnownHostsFile=~/.ssh/known_hosts \
"$SSH_USER@$SSH_HOST" << 'ENDSSH'
set -e
echo "Starting deployment..."
# Navigate to project directory (update this path)
cd /opt/cloud-mcp || {
echo "Error: Project directory not found"
exit 1
}
# Pull latest code
echo "Pulling latest code..."
git fetch origin
git checkout main || git checkout master
git pull origin main || git pull origin master
# Run deployment script
echo "Running deployment script..."
chmod +x deploy-gitea.sh
./deploy-gitea.sh
echo "Deployment completed!"
ENDSSH
# Cleanup
rm -f ~/.ssh/deploy_key