From b4b66905860d4db6da03a082be2730de9ce1f82a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=20Kl=C3=A4rner?= Date: Tue, 8 Oct 2024 16:50:27 +0200 Subject: [PATCH] fix: ensure setting /github/workdir as Git safe directory works always When running super-linter on in a self hosted runner based on Action Runner Controller in K8s container mode the /github/home directory is not neccesarily mounted. But since we expect this directory to exist super-linter fails to set /github/workspace as a Git safe directory: 2024-10-04 17:58:37 [INFO] Successfully validated GITHUB_WORKSPACE: /github/workspace 2024-10-04 17:58:37 [DEBUG] Configuring Git safe directories 2024-10-04 17:58:37 [DEBUG] Set /github/workspace as a Git safe directory error: could not lock config file /github/home/.gitconfig: No such file or directory 2024-10-04 17:58:37 [FATAL] Cannot configure /github/workspace as a Git safe directory. Making sure this directory exists in container image ensures that under no circumstances we can fail - if the action runner provides /github/home it will be mounted over, and if not we provide a directory where git can actually create the new .gitconfig. This also defaults the HOME environment variable to /github/home as it is the default in most places. So if somebody decides to override HOME they are also expected to ensure that this directory exists (or is a volume mount) --- Dockerfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Dockerfile b/Dockerfile index cd95b87c..056187aa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -435,6 +435,11 @@ ENV RENOVATE_X_IGNORE_RE2="true" ENV VERSION_FILE="/action/linterVersions.txt" RUN mkdir /action +# create the homedir, so that in case it is not present (like on action-runner-controller based selfhosted runners) +# we do not fail at setting /github/workspace as a safe git directory +ENV HOME="/github/home" +RUN mkdir -p "${HOME}" + ENTRYPOINT ["/action/lib/linter.sh"] FROM base_image AS slim