原创

github workflows配置


记录两个常用自动构建配置

.github/workflows/main.yml

部署静态文件

name: Deployement

on:
  push:
    branches:
      - main # 分支

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: node version
        run: node -v

      - name: npm version
        run: npm -v

      - name: Install and Build
        run: |#执行命令
          npm install
          npm run-script build
        env:
          CI: false

      - name: Deploy to GitHub Pages
        uses: JamesIves/github-pages-deploy-action@4.1.3
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          git-config-email: socialfi_xyz@gmail.com
          git-config-name: socialfi_xyz
          folder: build#部署文件夹
          branch: gh-pages#部署到分支(不要选当前分支或开发分支,会覆盖)
          clean: false

定时执行node脚本

name: CI
on:
  push:
    branches: [ master ]
  schedule:
    - cron: '*/5 * * * *'#5分钟执行一次
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: '15'
      - name: build
        run: npm install && npm run build
      - name: Deploy data
        uses: JamesIves/github-pages-deploy-action@4.1.3
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          git-config-email: web03
          git-config-name: web03
          folder: build
          branch: dataset
          clean: true

注意

token: ${{ secrets.GITHUB_TOKEN }}

此处这样写,就无需手动生成Actions secrets啦

入门知识
  • 作者:零三(联系作者)
  • 最后更新时间:2022-04-15 10:13
  • 版权声明:自由转载-非商用-非衍生-保持署名
  • 转载声明:来源地址 https://web03.cn