记录使用github action遇到的坑

122 阅读1分钟

想利用github Action 实现一下自动签到功能

一开始yaml文件如下

name: 京东签到
on:
  push:
  schedule:
    # `分 时 天 月 周` 时按照标准时间 北京时间=标准时间+8 18表示北京时间早上2点
    - cron: '0 18 * * *'
jobs:
  check_in:
    runs-on: ubuntu-latest
    steps:
      # 切换分支
     # - name: Checkout
     #   uses: actions/checkout@master


      # 使用 node:14
      - name: 使用 Node.js 14
        uses: actions/setup-node@v1
        with:
          node-version: 14

      # npm install
      - name: npm install
        run: |
          npm install
        env:
          CI: true

      # 运行脚本
      - name: 运行脚本
        run: |
          node app.js
        env:
          CI: true

运行时总是报错 Cannot find module 或者找不到package文件 后参考其他人写的文件发现需要加上切换分支功能