Anirban166 / Autocomment-atime-results

GitHub Action that automatically comments a plot and other atime-based results on PRs
https://github.com/marketplace/actions/autocomment-atime-results
0 stars 1 forks source link

Error when running git switch: 'detected dubious ownership' #8

Closed Anirban166 closed 8 months ago

Anirban166 commented 8 months ago
    # post checkout, action running on PR-based trigger
    - name: git-switch
      run: |
        git switch "${GITHUB_BASE_REF}"
        git switch "${GITHUB_HEAD_REF}"
      shell: bash  

Throws

Run git switch "${GITHUB_BASE_REF}" fatal: detected dubious ownership in repository at '/__w/<repository>'
To add an exception for this directory, call:

    git config --global --add safe.directory /__w/<repository>/<repository>

Error: Process completed with exit code 128.

After specifying the exception:

        ...
        git config --global --add safe.directory /__w/<repository>/<repository>
        # or git config --global --add safe.directory ${GITHUB_WORKSPACE}
        git switch "${GITHUB_BASE_REF}"
        git switch "${GITHUB_HEAD_REF}"
        ...

Or even removing all safe directory checks:

git config --global --add safe.directory '*'

There is an invalid reference when changing branches, right from the main branch:

...
fatal: invalid reference: main
Error: Process completed with exit code 128.