aliyun deploy #65
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |