jsk-ros-pkg / jsk_travis

11 stars 23 forks source link

move git config --add safe.directory after chown #445

Closed knorth55 closed 11 months ago

knorth55 commented 2 years ago
+ git config --global --add safe.directory /__w/jsk_travis/jsk_travis
error: could not lock config file /github/home/.gitconfig: Permission denied

https://github.com/jsk-ros-pkg/jsk_travis/runs/6121434102?check_suite_focus=true

This error does not causes CI error on jsk_travis, but in repo with submodules like jsk_apc.

fatal: unsafe repository ('/__w/jsk_apc/jsk_apc' is owned by someone else)
To add an exception for this directory, call:

    git config --global --add safe.directory /__w/jsk_apc/jsk_apc
Error: Process completed with exit code 128.

https://github.com/start-jsk/jsk_apc/runs/6246483890?check_suite_focus=true

knorth55 commented 2 years ago
fatal: unsafe repository ('/__w/jsk_apc/jsk_apc' is owned by someone else)
To add an exception for this directory, call:

    git config --global --add safe.directory /__w/jsk_apc/jsk_apc

hmmm, I still have error on submodules in noetic, I need to check more.

https://github.com/start-jsk/jsk_apc/runs/6246659126?check_suite_focus=true

knorth55 commented 2 years ago

My workaround is adding these lines after checkout for submodules. This might be useful for other repo with submodules like jsk_apc.

      - name: Checkout
        uses: actions/checkout@v2
      - name: work around permission issue again
        run: |
          set -x
          grep path $GITHUB_WORKSPACE/.gitmodules | sed 's/.*=//' | xargs -n 1 -I '{}' git config --global --add safe.directory $GITHUB_WORKSPACE/'{}'
knorth55 commented 2 years ago

I don't understand properly, but in order to avoid the permission problem, we first need to change the permission of the directory and then run git config --global.