Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/github/home/.gitconfig does not exist for container runs #1169

Open
arbourd opened this issue Feb 11, 2023 · 13 comments
Open

/github/home/.gitconfig does not exist for container runs #1169

arbourd opened this issue Feb 11, 2023 · 13 comments

Comments

@arbourd
Copy link

arbourd commented Feb 11, 2023

Issue

If running a job that uses a container like the below, the file /github/home/.gitconfig will not exist, even after checkout runs a config command.

  example:
    runs-on: ubuntu-latest
    container:
      image: alpine

Here is a demo:

  1. Checkout runs, and runs /usr/bin/git config --global --add safe.directory /__w/sat/sat
  2. The global .gitconfig does not exist
  3. Any calls to git remain unsafe/dubious

The safe.directory settings set by the command git config --global --add safe.directory <path> is a no-op.

Workaround

Use the --system scope over --global:

$ git config --system --add safe.directory <path>
  example:
    runs-on: ubuntu-latest
    container:
      image: alpine

    steps:
      - uses: actions/checkout@v3
      - run: git config --system --add safe.directory <path>
kobaltcore added a commit to kobaltcore/renpyfmt that referenced this issue Feb 11, 2023
kobaltcore added a commit to kobaltcore/renpyfmt that referenced this issue Feb 11, 2023
* Print some debug information

* Try potential fix

Via actions/checkout#1169 (comment)

* Would be great if I didn't fat-finger the fix, rip

* Remove debug prints
fracpete added a commit to waikato-ufdl/waikato-ufdl.github.io that referenced this issue Feb 13, 2023
@destroyersrt
Copy link

I tried the workaround but it doesn't seem to work in my case.

image

image

@arbourd
Copy link
Author

arbourd commented Feb 15, 2023

I tried the workaround but it doesn't seem to work in my case.

image image

Try without the sudo? Might ahve something to do with the Slither action itself too and if it spins up containers.

@destroyersrt
Copy link

At first I tried without sudo but got permission denied error.

@destroyersrt
Copy link

slither-action had issue crytic/slither-action#50. Thanks.

jagot added a commit to attoyss2023/attoyss2023.github.io that referenced this issue Feb 16, 2023
jagot added a commit to attoyss2023/attoyss2023.github.io that referenced this issue Feb 16, 2023
kamikazechaser added a commit to grassrootseconomics/cic-custodial that referenced this issue Feb 20, 2023
Erope added a commit to Erope/nezha that referenced this issue Mar 1, 2023
facebook-github-bot pushed a commit to facebook/CacheLib that referenced this issue Mar 2, 2023
Summary:
1. Workaround for Debian Docker image bug that is breaking Debian build on GitHub (Explicitly mark Git repo as safe).
2. Pin zstd to a commit that resolves problems with older CMakes (note: affects all OSes, not just Debian)

Context for 1: In latest Debian Docker image , there is a regression that affects the checkout action.

From actions/checkout#1169:
> - Checkout runs, and runs /usr/bin/git config --global --add safe.directory <path>
> - The global .gitconfig does not exist
> - Any calls to git remain unsafe/dubious

The suggested workaround was to use --system instead of --global.

Pull Request resolved: #200

Test Plan: See if GitHub Action Debian build is fixed.

Reviewed By: therealgymmy

Differential Revision: D43720363

Pulled By: jaesoo-fb

fbshipit-source-id: 54f3586cc7f8e72045e60d8dd454c7a77725e6b2
@LecrisUT
Copy link

Should note that the workaround described here is only for container runs

KywyErik added a commit to KOINSLOT-Inc/devkit that referenced this issue Jun 30, 2023
Looks like there's a `git` bug with Github Actions:
actions/checkout#1169. This commit implements
the workaround described in the issue thread.
KywyErik added a commit to KOINSLOT-Inc/devkit that referenced this issue Jun 30, 2023
Looks like there's a `git` bug with Github Actions:
actions/checkout#1169. This commit implements
the workaround described in the issue thread.
KywyErik added a commit to KOINSLOT-Inc/devkit that referenced this issue Jun 30, 2023
Looks like there's a `git` bug with Github Actions:
actions/checkout#1169. This commit implements
the workaround described in the issue thread.
facebook-github-bot pushed a commit to facebook/CacheLib that referenced this issue Aug 29, 2023
Summary:
In D48757822, we added the safe directory to the system gitconfig. However, for native runs
of workflows including Ubuntu-20 and Ubuntu-22, this does not work for permission error.
(see actions/checkout#1169)

This change fixes it by adding safe directory to global config instead.

Reviewed By: therealgymmy

Differential Revision: D48787452

fbshipit-source-id: dbe41ad42249e72d1c98e4af10ac977ba49b791d
@ST-DDT
Copy link

ST-DDT commented Sep 17, 2023

FFR: Using the users opzion might help here for the related issue:
actions/runner#2033 (comment)

lypoluz pushed a commit to lypoluz/ogdf that referenced this issue Sep 25, 2023
XComp added a commit to XComp/flink that referenced this issue Oct 10, 2023
XComp added a commit to XComp/flink that referenced this issue Oct 12, 2023
DifferentialOrange added a commit to DifferentialOrange/github-pages-deploy-action that referenced this issue Oct 23, 2023
XComp added a commit to XComp/flink that referenced this issue Oct 30, 2023
kimo-k added a commit to day8/re-frame that referenced this issue Nov 2, 2023
kimo-k added a commit to day8/re-frame that referenced this issue Nov 2, 2023
kimo-k added a commit to day8/re-frame that referenced this issue Nov 2, 2023
kimo-k added a commit to day8/re-frame that referenced this issue Nov 2, 2023
ZeroChaos- added a commit to ZeroChaos-/pkgcheck-action that referenced this issue Jan 17, 2024
pkgcheck uses git for some of it's checks, however, the github.workspace
directory not being marked safe causes a failure
See also: actions/checkout#1169
See also: https://github.com/pentoo/pentoo-overlay/actions/runs/7560749313/job/20587445443
Closes: pkgcore#18
Signed-of-by: Zero_Chaos <zerochaos@gentoo.org>
ZeroChaos- added a commit to ZeroChaos-/pkgcheck-action that referenced this issue Jan 17, 2024
pkgcheck uses git for some of it's checks, however, the github.workspace
directory not being marked safe causes a failure
See also: actions/checkout#1169
See also: https://github.com/pentoo/pentoo-overlay/actions/runs/7560749313/job/20587445443
Closes: pkgcore#18
Signed-off-by: Zero_Chaos <zerochaos@gentoo.org>
arthurzam pushed a commit to pkgcore/pkgcheck-action that referenced this issue Jan 17, 2024
pkgcheck uses git for some of it's checks, however, the github.workspace
directory not being marked safe causes a failure
See also: actions/checkout#1169
See also: https://github.com/pentoo/pentoo-overlay/actions/runs/7560749313/job/20587445443
Closes: #18
Signed-off-by: Zero_Chaos <zerochaos@gentoo.org>
Closes: #19
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
@theory
Copy link

theory commented Jan 20, 2024

I banged my head on what I think is this issue all day. Consider this config:

name: Test Git
on:
  push:
jobs:
  bundle:
    name: Git
    runs-on: ubuntu-latest
    container: alpine/git
    steps:
    - uses: actions/checkout@v4
    - run: git archive -v --format zip --prefix foo/ --output foo.zip HEAD

This results in this error:

fatal: detected dubious ownership in repository at '/__w/test-pgxn-tools/test-pgxn-tools'
To add an exception for this directory, call:

	git config --global --add safe.directory /__w/test-pgxn-tools/test-pgxn-tools

Shouldn't we be able to do Git stuff with the repo in a container? Curious, I tried changing the last line to:

    - run: git config safe.directory

It simply exits with no error message, as in this run:

Run git config safe.directory
  git config safe.directory
  shell: sh -e {0}
Error: Process completed with exit code 1.

Is that because the global config file is missing? I find it simply wild that there is no error message.

Anyway, I then tried setting the global config:

    - run: git config --global --add safe.directory "$PWD"

And that works. But I admit I'm pretty confused about why this isn't set up by default when an action starts.

So fine, I can manually put this line into my workflow YAML files, but I'm mystified as to why it's necessary. Is it this issue or am I missing something?

Thanks for bearing with my examples.

@theory
Copy link

theory commented Jan 20, 2024

It simply exits with no error message, as in this run:

FWIW I see the same error using actions/checkout@v3 in this build an using actions/checkout@v2 in this build. Color me confused.

@theory
Copy link

theory commented Jan 22, 2024

I'm fixing the issue in pgxn-tools by adding this line to the Dockerfile to disable the check inside the running container:

git config --system --add safe.directory '*'

Is there any reason that is likely to be a security issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants