前端
This commit is contained in:
@@ -1,51 +0,0 @@
|
|||||||
# ==========================================
|
|
||||||
# 纯 Bash SCP 部署工作流(零外部 Action 依赖)
|
|
||||||
# ==========================================
|
|
||||||
name: Deploy Frontend
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
deploy:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: http://192.168.31.185:3002/actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Deploy via SCP
|
|
||||||
run: |
|
|
||||||
set -e
|
|
||||||
|
|
||||||
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:="shuai"}
|
|
||||||
: ${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
|
|
||||||
printf '%s\n' "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
|
|
||||||
chmod 600 ~/.ssh/id_ed25519
|
|
||||||
|
|
||||||
# 确保目标目录存在,并清空旧文件
|
|
||||||
ssh -o StrictHostKeyChecking=accept-new -i ~/.ssh/id_ed25519 -p "${SERVER_PORT}" \
|
|
||||||
"${SERVER_USER}@${SERVER_HOST}" "mkdir -p ${TARGET_DIR} && rm -rf ${TARGET_DIR}/*"
|
|
||||||
|
|
||||||
# SCP 上传
|
|
||||||
echo "🚀 开始上传文件..."
|
|
||||||
scp -o StrictHostKeyChecking=accept-new -i ~/.ssh/id_ed25519 -P "${SERVER_PORT}" -r \
|
|
||||||
./* \
|
|
||||||
"${SERVER_USER}@${SERVER_HOST}:${TARGET_DIR}/"
|
|
||||||
|
|
||||||
echo "✨ 部署成功!"
|
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
name: Deploy Static Frontend
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ci-base
|
||||||
|
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: http://192.168.31.185:3002/actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Deploy via RSYNC
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
|
||||||
|
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:="shuai"}
|
||||||
|
: ${SERVER_PORT:="2222"}
|
||||||
|
: ${TARGET_DIR:="/data/apps/ci-cd/frontend"}
|
||||||
|
|
||||||
|
echo "Deploy to ${SERVER_USER}@${SERVER_HOST}:${TARGET_DIR}"
|
||||||
|
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
chmod 700 ~/.ssh
|
||||||
|
|
||||||
|
printf '%s\n' "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
|
||||||
|
chmod 600 ~/.ssh/id_ed25519
|
||||||
|
|
||||||
|
ssh-keyscan -p "${SERVER_PORT}" -H "${SERVER_HOST}" >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
|
ssh -i ~/.ssh/id_ed25519 -p "${SERVER_PORT}" \
|
||||||
|
"${SERVER_USER}@${SERVER_HOST}" \
|
||||||
|
"mkdir -p ${TARGET_DIR}"
|
||||||
|
|
||||||
|
rsync -avz --delete \
|
||||||
|
-e "ssh -i ~/.ssh/id_ed25519 -p ${SERVER_PORT}" \
|
||||||
|
--exclude ".git" \
|
||||||
|
--exclude ".gitea" \
|
||||||
|
./ \
|
||||||
|
"${SERVER_USER}@${SERVER_HOST}:${TARGET_DIR}/"
|
||||||
|
|
||||||
|
echo "Deploy success"
|
||||||
Reference in New Issue
Block a user