ci: 手动触发 workflow_dispatch + 纯 run 部署
This commit is contained in:
@ -1,18 +1,22 @@
|
||||
name: deploy
|
||||
on:
|
||||
push:
|
||||
branches: [main, master]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: docker
|
||||
steps:
|
||||
- name: SSH 到服务器执行上线脚本
|
||||
uses: appleboy/ssh-action@v1
|
||||
with:
|
||||
host: ${{ secrets.DEPLOY_HOST }}
|
||||
username: ${{ secrets.DEPLOY_USER }}
|
||||
key: ${{ secrets.DEPLOY_KEY }}
|
||||
script: |
|
||||
cd /opt/fashion/test
|
||||
./deploy.sh
|
||||
- name: SSH deploy
|
||||
shell: sh
|
||||
env:
|
||||
KEY_B64: ${{ secrets.DEPLOY_KEY_B64 }}
|
||||
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
||||
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
|
||||
run: |
|
||||
set -e
|
||||
apk add --no-cache openssh-client >/dev/null 2>&1 || true
|
||||
mkdir -p "$HOME/.ssh"
|
||||
echo "$KEY_B64" | base64 -d > "$HOME/.ssh/id"
|
||||
chmod 600 "$HOME/.ssh/id"
|
||||
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "$HOME/.ssh/id" \
|
||||
"$DEPLOY_USER@$DEPLOY_HOST" "cd /opt/fashion/backend_v2 && ./deploy.sh web"
|
||||
|
||||
Reference in New Issue
Block a user