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/[email protected]
        with:
          token: ${
   
   { secrets.GITHUB_TOKEN }}
          git-config-email: [email protected]
          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/[email protected]
        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啦
注意
定时任务间隔是不准确的

猜你喜欢

转载自blog.csdn.net/weixin_43840202/article/details/125258628