我正在嘗試設定 GitHub 操作以檢查 lint 錯誤并在檢測到任何錯誤/警告時使拉取請求失敗。
目前我的邏輯在本地作業,但是當我嘗試通過 GitHub 操作運行它時,出現錯誤:
致命:模棱兩可的引數“原點/主...HEAD”:未知的修訂版或路徑不在作業樹中。
我相信這與checkout@v2沒有獲取正確數量的資料有關,但我無法理解是什么
代碼示例
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)
uj5u.com熱心網友回復:
你可能需要做一個checkout@v1為在這個例子中得到的所有檔案。
- uses: actions/checkout@v1
...
- run: git diff ${{ github.event.pull_request.base.sha }} ${{ github.sha }}
v2 默認只獲取觸發動作的 sha。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/345709.html
