From 0181a8bea44aa348993a3d77a9cdce7a59c4f709 Mon Sep 17 00:00:00 2001 From: Sebastian Kuzminsky Date: Mon, 7 Nov 2022 17:44:22 -0700 Subject: [PATCH] tell git to trust the repo Recent versions of git do not like to run as root in repos that are not owned by root. This is commonly the situation when a user checks out a git repo, then runs a docker container with the repo mounted in it. The version un debian unstable (1:2.38.1-1) has this issue. The version in bullseye (1:2.30.2-1) does not have this issue. git-deborig gives this unhelpful error message: $ git deborig HEAD pwd doesn't look like a git repository .. Regular git gives this more useful error message: $ git status fatal: detected dubious ownership in repository at '/data/home/seb/action-debian-package' To add an exception for this directory, call: git config --global --add safe.directory /data/home/seb/action-debian-package This commit fixes the issue by running the recommended command inside the container, before trying to access the git repo. Fixes #62. --- main.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/main.js b/main.js index 8198b4d..5d9a132 100644 --- a/main.js +++ b/main.js @@ -155,6 +155,15 @@ async function main() { ]) core.endGroup() + core.startGroup("Trust this git repo") + await exec.exec("docker", [ + "exec", + container, + "bash", "-c", + "git config --global --add safe.directory ${PWD}" + ]) + core.endGroup() + if (imageTag != "trusty") { core.startGroup("Install build dependencies") await exec.exec("docker", [