feat: support to control cert file automatically #15
This file contains hidden or 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: Deploy mkBlog to server machine | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Prepare deploy key file | |
| run: | | |
| mkdir -p ~/.ssh | |
| # 写入 secret(不要在日志中打印密钥) | |
| echo "$SSH_PRIVATE_KEY" > ~/.ssh/deploy_key | |
| # 删除可能的 CRLF | |
| sed -i 's/\r$//' ~/.ssh/deploy_key || true | |
| chmod 600 ~/.ssh/deploy_key | |
| env: | |
| SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | |
| - name: Add SSH known host | |
| run: ssh-keyscan -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts | |
| - name: Git pull files | |
| run: | | |
| ssh -o BatchMode=yes -i ~/.ssh/deploy_key ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} \ | |
| "cd ${{ secrets.REMOTE_REPO_PATH }} && git pull origin main" | |
| - name: Run remote deploy commands using key file | |
| run: | | |
| ssh -o BatchMode=yes -i ~/.ssh/deploy_key ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} \ | |
| "cd ${{ secrets.REMOTE_REPO_PATH }} && make all" |