github action

发表于:2022-01-11 00:26
github,运维
热度:90
喜欢:0

利用github action,在提交之后,自动将hexo打包后的内容推送到服务器上

yml 复制代码
name: auto-publish

on:
  push:
    branches:
      - workflows
      - master

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: 缓存
        uses: actions/cache@v2
        with:
          path: ~/.npm
          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-node-

      - name: Checkout
        uses: actions/checkout@master

      - name: build
        uses: actions/setup-node@v1

      - name: install
        run: npm install

      - name: generate
        run: npm run g

      - name: deploy
        uses: appleboy/scp-action@master
        with:
          host: ${{ secrets.HOST }}
          username: ${{ secrets.USERNAME }}
          password: ${{ secrets.PASSWORD }}
          port: ${{ secrets.PORT }}
          source: "public/*"
          target: "/www/wwwroot/blog.nnnnzs.cn/"

      - run: cd public && ls