-
Notifications
You must be signed in to change notification settings - Fork 119
39 lines (38 loc) · 1.31 KB
/
aliyun_deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
name: aliyun deploy
on:
push:
branches:
- main
workflow_dispatch:
workflow_run:
workflows: ["update_cache"]
types:
- completed
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Compile the frontend
run: |
cd web-vue && npm install && npm run build
- name: Deploy to aliyun server
uses: easingthemes/ssh-deploy@v2.0.7
env:
SSH_PRIVATE_KEY: ${{ secrets.ALIYUN_SERVER_ACCESS_TOKEN }}
ARGS: "-avzr --delete --exclude='.git/' --exclude='__pycache__/'"
SOURCE: "."
REMOTE_HOST: ${{ secrets.ALIYUN_SERVER_HOST }}
REMOTE_USER: ${{ secrets.ALIYUN_REMOTE_USER }}
TARGET: ${{ secrets.ALIYUN_TARGET }}
- name: Restart service
env:
REMOTE_HOST: ${{ secrets.ALIYUN_SERVER_HOST }}
REMOTE_USER: ${{ secrets.ALIYUN_REMOTE_USER }}
SSH_PRIVATE_KEY: ${{ secrets.ALIYUN_SERVER_ACCESS_TOKEN }}
run: |
mkdir -p ~/.ssh
echo "${{ env.SSH_PRIVATE_KEY }}" | tr -d '\r' > ~/.ssh/id_rsa
chmod 700 ~/.ssh/id_rsa
ssh-keyscan -H "${{ env.REMOTE_HOST }}" >> ~/.ssh/known_hosts
ssh -o StrictHostKeyChecking=no "${{ env.REMOTE_USER }}@${{ env.REMOTE_HOST }}" "sudo systemctl restart myapp"