diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b6e9921c..1481fd8e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,8 +15,6 @@ jobs: defaults: run: shell: bash -l {0} - env: - BRANCH_NAME: ${{ github.head_ref || github.ref_name }} steps: - name: Checkout code uses: actions/checkout@v4 @@ -28,13 +26,16 @@ jobs: environment-file: environment.yml channel-priority: flexible miniforge-variant: Miniforge3 + - name: Get the latest commit hash and target ref + run: | + echo "COMMIT_HASH=$(git log -1 --format='%H')" >> $GITHUB_ENV + echo "REF=${{ github.event.pull_request.base.ref || github.ref_name }}" >> $GITHUB_ENV - name: Run Pre-Commit run: | - echo $BRANCH_NAME - echo ${{ github.event.pull_request.base.ref }} - echo ${{ github.event.pull_request.head.sha }} + echo $REF + echo $COMMIT_HASH git fetch origin - pre-commit run --from-ref origin/${{ github.event.pull_request.base.ref }} --to-ref ${{ github.event.pull_request.head.sha }} + pre-commit run --from-ref origin/$REF --to-ref $COMMIT_HASH test-dev: runs-on: ubuntu-latest