peaceiris / actions-hugo

GitHub Actions for Hugo ⚡️ Setup Hugo quickly and build your site fast. Hugo extended, Hugo Modules, Linux (Ubuntu), macOS, and Windows are supported.
https://github.com/marketplace/actions/hugo-setup
MIT License
1.38k stars 80 forks source link

support: fatal: unsafe repository #579

Closed kaihendry closed 2 years ago

kaihendry commented 2 years ago

Checklist

Describe your question

Build failure when it worked before: https://github.com/kaihendry/dabase.com/runs/6157428721?check_suite_focus=true

Relevant links

https://github.com/kaihendry/dabase.com/blob/master/.github/workflows/hugo.yml

Relevant log output

hugo v0.97.3-078053a43d746a26aa3d48cf1ec7122ae78a9bb4+extended linux/amd64 BuildDate=2022-04-18T17:22:19Z VendorInfo=gohugoio
ERROR 2022/04/25 12:31:10 Failed to read Git log: fatal: unsafe repository ('/__w/dabase.com/dabase.com' is owned by someone else)
To add an exception for this directory, call:

    git config --global --add safe.directory /__w/dabase.com/dabase.com
WARN 2022/04/25 12:31:11 .File.BaseFileName on zero object. Wrap it in if or with: {{ with .File }}{{ .BaseFileName }}{{ end }}
Error: Error building site: logged 1 error(s)

Additional context.

Thank you for this project!

peaceiris commented 2 years ago

Please try actions/checkout@v3

kaihendry commented 2 years ago

Same issue? https://github.com/kaihendry/dabase.com/runs/6168349857?check_suite_focus=true

peaceiris commented 2 years ago

It seems to should be fixed in the peaceiris/hugo docker image. As a workaround, we can run git config --global --add safe.directory / before hugo step.

peaceiris commented 2 years ago

https://github.com/peaceiris/hugo-extended-docker/pull/79

kaihendry commented 2 years ago

I just re-ran and it still fails... Do I just wait? :grimacing:

https://github.com/kaihendry/dabase.com/runs/6168545815?check_suite_focus=true

peaceiris commented 2 years ago

You can try the image ghcr.io/peaceiris/hugo:test

peaceiris commented 2 years ago

Or peaceiris/hugo:test

kaihendry commented 2 years ago

Still fails? https://github.com/kaihendry/dabase.com/runs/6170692004?check_suite_focus=true

peaceiris commented 2 years ago

Currently, we can add the following command before hugo building to avoid the error.

This looks like the current better measure since it is difficult to know a GITHUB_WORKSPACE directory when a Docker image is built.

cf. Git security vulnerability announced | The GitHub Blog

jobs:
  build:
    runs-on: ubuntu-20.04
    container: peaceiris/hugo:v0.97.3
    steps:
      - uses: actions/checkout@v3
      - name: Build and Deploy
        run: |
          git config --global --add safe.directory ${GITHUB_WORKSPACE}
          hugo
kaihendry commented 2 years ago

Thanks for your help! I'll buy you a beer in Singapore https://github.com/kaihendry/dabase.com/runs/6186503865?check_suite_focus=true

github-actions[bot] commented 2 years ago

This issue has been LOCKED because of it being resolved!

The issue has been fixed and is therefore considered resolved. If you still encounter this or it has changed, open a new issue instead of responding to solved ones.

Log | Bot Usage