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

git commands are failed when used as github action in node:lts-hydrogen container #769

Closed
DKurilo opened this issue Jun 14, 2023 · 2 comments
Labels
bug Classification: Something isn't working needs triage Tracking: Issue needs confirmation

Comments

@DKurilo
Copy link

DKurilo commented Jun 14, 2023

Bug report

We have such an error when running as github action in node:lts-hydrogen container:

    → Command failed with exit code 128: git --no-pager log -n 1 --format="%H ## %ct ## %ae ## %an"
fatal: detected dubious ownership in repository at '/__w/*****/*****'
To add an exception for this directory, call:

	git config --global --add safe.directory /__w/*****/*****

✖ Failed to retrieve git information

To avoid this chromaui/action just should do what git asked for, for example in actions/checkout there is parameter in input settings that is running this: https://github.com/actions/checkout/blob/96f53100ba2a5449eb71d2e6604bbcd94b9449b5/action.yml#L80
that is doing this:
https://github.com/actions/checkout/blob/96f53100ba2a5449eb71d2e6604bbcd94b9449b5/src/git-source-provider.ts#L43

Can we add the same into chromaui/action, please?

Upd:
Main issue here is docker uses not the same user id and group id as underlying host. So solution is here:
actions/runner#691
I'm closing it.

@DKurilo DKurilo added bug Classification: Something isn't working needs triage Tracking: Issue needs confirmation labels Jun 14, 2023
@DKurilo DKurilo closed this as completed Jun 14, 2023
@GMartigny
Copy link

Hi @DKurilo,

Could you explains the steps you took to solve this issue. I'm not well verse in GitHub actions and I couldn't make the workaround work.

My base Chromatic job

jobs:
  Code-quality:
    ...
  Tests:
    ...
  Chromatic:
    needs: [Code-quality, Tests]
    runs-on: ubuntu-latest
    container:
      image: node:20
    steps:
      - uses: actions/checkout@v4
      - uses: actions/cache@v4
        with:
          path: node_modules/
          key: "${{ runner.os }}-${{ hashFiles('package-lock.json') }}"
      - name: Run Chromatic
        uses: chromaui/action@latest
        with:
          projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
          onlyChanged: true
          exitOnceUploaded: true

@DKurilo
Copy link
Author

DKurilo commented Nov 21, 2024

Hi @GMartigny ,
It was long time ago. I really even don't remember I wrote this. But it looks like I didn't left it without answer. Just read my Upd. :)
So I think in your case something like this can help:

jobs:
  Code-quality:
    ...
  Tests:
    ...
  configure:
    runs-on: ubuntu-latest
    outputs:
      uid_gid: ${{ steps.get-user.outputs.uid_gid }}
    steps:
      - id: get-user
        run: echo "::set-output name=uid_gid::$(id -u):$(id -g)"
  Chromatic:
    needs: [Code-quality, Tests, configure]
    runs-on: ubuntu-latest
    container:
      image: node:20
      options: --user ${{ needs.configure.outputs.uid_gid }}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/cache@v4
        with:
          path: node_modules/
          key: "${{ runner.os }}-${{ hashFiles('package-lock.json') }}"
      - name: Run Chromatic
        uses: chromaui/action@latest
        with:
          projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
          onlyChanged: true
          exitOnceUploaded: true

I hope it helped. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Classification: Something isn't working needs triage Tracking: Issue needs confirmation
Projects
None yet
Development

No branches or pull requests

2 participants