From b3199aebf7ef6370546a9a068f4bf9778f244d7a Mon Sep 17 00:00:00 2001 From: Harry Saunders Date: Wed, 27 Sep 2023 16:34:17 +0100 Subject: [PATCH] Try to fix CI git error When attempting to run the pre-commit hooks in the CI, we get this error: An error has occurred: FatalError: git failed. Is it installed, and are you in a Git repository directory? https://github.com/actions/checkout/issues/766 suggests the issue could be because 'actions/checkout' clones the repository as a different user than is used in our custom docker container. Git then doesn't trust the repository and errors when called upon. --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5382c12..a566a97 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,6 +17,10 @@ jobs: - uses: actions/checkout@v3 - name: Quality Checks run: | + # As we're running in our own container, we're not the same user as is + # used by 'actions/checkout', so git operations fail. + # https://github.com/actions/checkout/issues/766 + git config --global --add safe.directory "$GITHUB_WORKSPACE" pip install pre-commit pre-commit install pre-commit run --all