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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| name: Deploy
on: push: branches: - main
jobs: deploy: runs-on: ubuntu-latest concurrency: group: deploy-group-hexo cancel-in-progress: false steps: - name: Checkout code uses: actions/checkout@v2 with: submodules: true ref: hexo
- name: Set up Node.js uses: actions/setup-node@v2 with: node-version: '18.20.4'
- name: Print current working directory run: pwd
- name: Install dependencies run: npm install
- name: Build Hexo run: | npm install -g hexo hexo clean hexo generate sleep 5 hexo generate
- name: Set up SSH key run: | mkdir -p ~/.ssh echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa chmod 600 ~/.ssh/id_rsa echo "Host *" > ~/.ssh/config echo " StrictHostKeyChecking no" >> ~/.ssh/config chmod 600 ~/.ssh/config
- name: Deploy to server run: | ssh ${{ secrets.USERNAME }}@${{ secrets.SERVER_IP }} "rm -rf /home/zjh199/domains/hexo.kongshan.cc/public_html" rsync -avz --delete ./public/ ${{ secrets.USERNAME }}@${{ secrets.SERVER_IP }}:/home/zjh199/domains/hexo.kongshan.cc/public_html # ssh ${{ secrets.USERNAME }}@${{ secrets.SERVER_IP }} "rm -rf /opt/application/hexo/public"ssh ${{ secrets.USERNAME }}@${{ secrets.SERVER_IP }} "node /opt/application/hexo/source/_posts/.script/send.mjs" env: SERVER_IP: ${{ secrets.SERVER_IP }} USERNAME: ${{ secrets.USERNAME }} SSH_PORT: ${{ secrets.SSH_PORT }} GIT_USERNAME: ${{ secrets.GIT_USERNAME }} GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
|