checkout icon indicating copy to clipboard operation
checkout copied to clipboard

GH#354 Avoid auth configuration for submodules when settings.submodules is false

Open cosimo opened this issue 4 years ago • 2 comments

This patch appears to solve the problems detailed in #354 and possibly #385. The question is: is this the correct way to solve the problem? Not sure.

The conditions to reproduce the problem are the following:

  • use self-hosted github runners (in our case within docker containers, I have no idea if that's a general way to do things)
  • have a private (org-wide) shared actions repository in addition to marketplace actions like actions/checkout, etc...
  • use the workaround detailed in https://github.community/t/github-action-action-in-private-repository/16063/43 to checkout a private org-wide actions, thus using two actions/checkout@v2 steps, one for the main project and one for the private shared actions repository.

Something happens in the "Setting up auth" stage: the additional directory used for the private shared actions repository checkout within the existing project checkout (whatever that directory is called), is interpreted as a submodule (?) when running the auth helper removeGitConfig() and this results in the following error messages:

/usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :
  Error: fatal: No url found for submodule path '.github/my-org-github-actions' in .gitmodules
  Error: The process '/usr/bin/git' failed with exit code 128

Note that no repository involved has submodules here.

An alternative solution that seems to work is manual removal ~of the private actions repository checkout directory~ of the entire project checkout.

UPDATE: I see now that the git index is being updated with the shared actions checkout directory, even though I don't think I have done that explicitly.

Here's most of the failing checkout messages:

  /usr/bin/git rev-parse --symbolic-full-name --verify --quiet HEAD
  refs/heads/main
  /usr/bin/git checkout --detach
  HEAD is now at 090f36f <Description of commit here>
  D	.github/my-org-github-actions                                              <--- *** THIS ***
  /usr/bin/git rev-parse --symbolic-full-name --branches
  refs/heads/main
  /usr/bin/git branch --delete --force main
  Deleted branch main (was 090f36f).
  /usr/bin/git rev-parse --symbolic-full-name --remotes=origin
  refs/remotes/origin/main
Cleaning the repository
  /usr/bin/git clean -ffdx
  /usr/bin/git reset --hard HEAD
  HEAD is now at 090f36f <Description of commit here>
Disabling automatic garbage collection
Setting up auth
  /usr/bin/git config --local --name-only --get-regexp core\.sshCommand
  /usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :
  Error: fatal: No url found for submodule path '.github/my-org-github-actions' in .gitmodules
  Error: The process '/usr/bin/git' failed with exit code 128

cosimo avatar Jan 13 '21 08:01 cosimo

We've found a good workaround, which is to simply add the directory name for the private actions checkout to .gitignore.

cosimo avatar Jan 21 '21 21:01 cosimo

Please add fixes #354 to the description

jsoref avatar Aug 22 '22 19:08 jsoref

I'm running with this merged into https://github.com/check-spelling/actions-checkout/releases/tag/v3 as part of https://github.com/check-spelling/check-spelling/commit/407076ce6b63ad13212ef233a146c5a1bd479b94 in order to resolve the problem that this PR fixes in repositories such as https://github.com/check-spelling/winget-cli/actions/runs/3570503478/attempts/1 -- with this applied, things are happy: https://github.com/check-spelling/winget-cli/actions/runs/3571395765/jobs/6003227245#step:2:1

I expect to leave this tag in place (and possibly pull in other things as needed) until it's merged into actions/checkout@v3 ...

@cory-miller: what would it take to move this along?

jsoref avatar Nov 29 '22 05:11 jsoref

Can you incorporate the fix from https://github.com/actions/checkout/pull/964 to address the merge conflict? Other than that LGTM.

cory-miller avatar Dec 13 '22 22:12 cory-miller

@cory-miller, I don't have write access to this PR, but I'm hosting a rebased version of the changes here: https://github.com/actions/checkout/commit/c12e7286cb39113c32dd06ac576ed748853ee61e, you should be able to force push the branch to it.

I've moved https://github.com/check-spelling/actions-checkout/releases/tag/v3 to that commit.

jsoref avatar Jan 04 '23 06:01 jsoref