Answer a question

I'm trying to setup GitHub action to check for lint errors and fail the pull request if any error/ warnings detected.

Currently my logic works locally but when I try to run it via GitHub action, I get an error:

fatal: ambiguous argument 'origin/master...HEAD': unknown revision or path not in the working tree.

I believe it's something to do with checkout@v2 not fetching the right amount of data, But I cant get my head around what

Code Sample

name: Initiate PR
on: push
jobs:
  STEPS:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 100
      - name: Set up Node.js
        uses: actions/setup-node@v1
        with:
          node-version: 14.18.0
      - name: Install Node.js dependencies
        run: npm ci --ignore-scripts
      - name: lint-on-PR
        shell: bash
        run: |
          npx eslint --max-warnings 0 $(git diff origin/master...HEAD --name-only --relative --diff-filter=MATR '***.js' '***.jsx' '***.ts' '***.tsx' | xargs)

Answers

You would probably need to do a checkout@v1 as in this example to get all the files.

- uses: actions/checkout@v1
...
- run: git diff ${{ github.event.pull_request.base.sha }} ${{ github.sha }}

v2 by default only fetches the sha that triggered the action.

Logo

ModelScope旨在打造下一代开源的模型即服务共享平台,为泛AI开发者提供灵活、易用、低成本的一站式模型服务产品,让模型应用更简单!

更多推荐