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

[BUG] <Error: Can't find local .git directory> #1840

Closed
4 tasks done
bbaral07 opened this issue Jan 12, 2024 · 6 comments
Closed
4 tasks done

[BUG] <Error: Can't find local .git directory> #1840

bbaral07 opened this issue Jan 12, 2024 · 6 comments
Labels
bug Something isn't working requires-feedback

Comments

@bbaral07
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Does this issue exist in the latest version?

  • I'm using the latest release

Describe the bug?

Error: Can't find local .git directory. Please run actions/checkout before this action

To Reproduce

In the github work flow, (using Github Enterprise);

  1. I do a repo checkout with github actions/checkout@v4,
  2. then I use the tj-actions/changed-files@v41
    But after checkout when it runs the changed files action, it gives the following error:::

changed-files
Error: Can't find local .git directory. Please run actions/checkout before this action

Have checked the repo,
it contains the .git folder.

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-22.04

Expected behavior?

should return the changed files list.

Relevant log output

Run tj-actions/changed-files@v41
with: 
  <default>
/usr/bin/docker exec  b93336f5c3ceb6d64f6ffd1fb2620ace4c3e8f68d0d6c681fddc76dbb322e110 sh -c "cat /etc/*release | grep ^ID"
changed-files
  Error: Can't find local .git directory. Please run actions/checkout before this action

Has all relevant logs been included?

  • I've included all relevant logs

Anything else?

changed-files actions error

Code of Conduct

  • I agree to follow this project's Code of Conduct
@bbaral07 bbaral07 added the bug Something isn't working label Jan 12, 2024
@jackton1
Copy link
Member

Hi @bbaral07 can you provide details of your workflow file. Include sections of both the checkout action and the changed-files action

@jackton1
Copy link
Member

jackton1 commented Jan 12, 2024

Hi @bbaral07 I'll suggest specifying the correct path input if you're checking out the repository in another folder.

You can search for "Get all changed files for a repository located in a different path" in the Examples section.

@jackton1 jackton1 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 12, 2024
@bbaral07
Copy link
Author

Hallo Jackton1,
thanks for your reply,
Below is the workflow part, where I do a checkout and then use the tj-actions/changed-files.
I followed the examples, but not sure if I am missing anything. Any hint or help is appreciated.
This is the point where I get the error (as in the original post)

  - name: Repo Checkout
    uses: actions/checkout@v4
    with:
      repository: org/tf_accounts
      ref: 'feature'
      fetch-depth: 0
      clean: 'false'

  - name: List the checkedout folders
    shell: bash
    run: |
      pwd
      ls -al
      printf "\n%s\n" "${GITHUB_WORKSPACE}"

  - name: Get all changed account json files
    id: changed-account-files
    if: contains(fromJson('["push", "pull_request"]'), github.event_name)
    uses: tj-actions/changed-files@v41
    with:
      files: accounts/*.{json}  # Alternatively using: `accounts/**`
      files_ignore: accounts/schema.json
      json: "true"
      write_output_files: true
      path: .

@jackton1
Copy link
Member

jackton1 commented Jan 17, 2024

Hi @bbaral07, thanks for sharing a couple of things to point out.

files: You might want to use accounts/*.json since you don’t need braces here.
path: defaults to . so no need to specify the same value.


Question: Is there a reason you have set clean: 'false'?


Request: To fully get to a solution. Can you include the debug logs of the workflow not a picture or snippet but if possible the entire logs. To obtain the debug logs you’ll need to rerun the workflow and ensure debug logging is enabled prior to rerunning the workflow.

Screenshot 2023-08-31 at 5 51 33 PM

@bbaral07
Copy link
Author

Thanks, Jackton01 for your response.
Sorry for the delayed response.
I tried to hardcode the path, but still, it could not process the result to find the changed files.
I used (clean: 'false') to retain the .git folder as I received an error that it could not find the correct .git folder.
Alternatively, I wrote a short shell script to get the changed files instead of using the action.

Though I could not use it, I truly appreciate the purpose and functionality of this action.
Great Job. 👏
Maybe I will try in some other workflow.

@jackton1
Copy link
Member

Sounds good, FYI the changed-files action doesn't only check that the .git folder exists but also validates the output of

git rev-parse --is-inside-work-tree which should return "true".

If you run into this issue in the future this would help you determine what's wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working requires-feedback
Projects
None yet
Development

No branches or pull requests

2 participants