Files
CI-CD/.gitea/workflows/deploy.yml
T
Shuai 3f51039121
Deploy Frontend / deploy (push) Failing after 12s
不使用镜像
2026-06-20 00:32:20 +08:00

59 lines
1.7 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.
# ==========================================
# 纯 Bash SCP 部署工作流(零外部 Action 依赖)
# ==========================================
name: Deploy Frontend
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Deploy via SCP
run: |
SERVER_HOST="${{ secrets.SSH_HOST }}"
SERVER_USER="${{ secrets.SSH_USER }}"
SERVER_PORT="${{ secrets.SSH_PORT }}"
TARGET_DIR="${{ secrets.TARGET_DIR }}"
: ${SERVER_HOST:="192.168.31.185"}
: ${SERVER_USER:="root"}
: ${SERVER_PORT:="2222"}
: ${TARGET_DIR:="/data/apps/ci-cd/frontend"}
echo "🌐 部署至 ${SERVER_USER}@${SERVER_HOST}:${TARGET_DIR} (端口: ${SERVER_PORT})"
# 配置 SSH 密钥
mkdir -p ~/.ssh
chmod 700 ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
# 扫描主机指纹
ssh-keyscan -p "${SERVER_PORT}" -H "${SERVER_HOST}" >> ~/.ssh/known_hosts 2>/dev/null
# 确保目标目录存在
ssh -i ~/.ssh/id_ed25519 -p "${SERVER_PORT}" \
"${SERVER_USER}@${SERVER_HOST}" \
"mkdir -p ${TARGET_DIR}"
# SCP 上传(排除 .git .gitea .github
echo "🚀 开始上传文件..."
scp -i ~/.ssh/id_ed25519 -P "${SERVER_PORT}" -r \
./* \
"${SERVER_USER}@${SERVER_HOST}:${TARGET_DIR}/"
if [ $? -eq 0 ]; then
echo "✨ 部署成功!"
else
echo "❌ 部署失败"
exit 1
fi