Files
cloud-mcp/.gitea/workflows/deploy-simple.yml

65 lines
1.8 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: Deploy to Server (Simple)
on:
push:
branches:
- main
- master
workflow_dispatch:
jobs:
deploy:
# 使用 self-hosted runner匹配任何自托管 Runner
# 或者使用你实际注册的 Runner 标签
runs-on: self-hosted
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