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

Image no longer works in GitHub Actions #29

Closed
arbourd opened this issue Feb 11, 2023 · 10 comments
Closed

Image no longer works in GitHub Actions #29

arbourd opened this issue Feb 11, 2023 · 10 comments

Comments

@arbourd
Copy link

arbourd commented Feb 11, 2023

Due to a bug in actions/checkout, this action cannot be used as a container without an additional step:

- run: git config --system --add safe.directory <path>

This is not unique to goreleaser-cross and will affect all versions until actions/checkout is fixed.

But, in the meantime, there is a method we can apply to the image that will allow it work without that extra step in the workflows. We could bake the command into the image itself with something like:

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

This would effectively disable the safe directory functionality within the goreleaser-cross container.

@troian
Copy link
Member

troian commented Feb 11, 2023

interesting, so this does not work? needs to be a wildcard * ?

@arbourd
Copy link
Author

arbourd commented Feb 11, 2023

Oh, I didn't know that was even in there! No, the pwd should be fine and it's a better/safer solution than what I suggested. The wildcard would match everything.

It might still be broken in actions because the global config doesn't seem to exist properly. Let me test with the latest v1.20.0 -- I was using v1.19.4 earlier.

@troian
Copy link
Member

troian commented Feb 11, 2023

try image from ghcr.io

@arbourd
Copy link
Author

arbourd commented Feb 11, 2023

Appears to be unresolved:

  ⨯ release failed after 0s                  error=current folder is not a git repository

The error "not a git repository" is due to the rev-parse command failing, due to an unsafe/dubious folder.

I will build and try --system over --global and see if that resolves it tomorrow/Monday.

@troian
Copy link
Member

troian commented Feb 14, 2023

i think the best option would be to keep an extra run step instead of adding it goreleaser-cross and wait till checkout/action makes a fix

@kamikazechaser
Copy link

For those who are facing the same issue, here is a fix:

jobs:
  goreleaser:
    runs-on: ubuntu-latest
    container:
      image: goreleaser/goreleaser-cross
    environment: build
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Workaround Git Security Warning
        run: |
          # Workaround a bug in github actions:
          git config --global --add safe.directory "$GITHUB_WORKSPACE"          
      - name: Set up Go
        uses: actions/setup-go@v2
        with:
          go-version: 1.19

@MickStanciu
Copy link

Hey guys!
I have the same problem but cannot solve it with the workaround posted above. I am using docker to trigger go releaser cross compile:

docker run......ghcr.io/goreleaser/goreleaser-cross:1.20.1 -f .goreleaser.yml release --clean

The error is:
• starting release... • loading config file file=.goreleaser.yml • loading environment variables • using token from "$GITHUB_TOKEN" • getting and validating git state ⨯ release failed after 0s error=current folder is not a git repository

Any suggestions? Thank you

@troian
Copy link
Member

troian commented Feb 22, 2023

how do you mount workdir to docker?

Erope added a commit to Erope/nezha that referenced this issue Mar 1, 2023
@MickStanciu
Copy link

how do you mount workdir to docker?

Hi troian, this is the full command:

docker run \ --rm \ --privileged \ --entrypoint ./goreleaser_entry.sh \ --env-file .release-env \ -v /var/run/docker.sock:/var/run/docker.sock \ -v pwd:/go/src/$(PACKAGE_NAME) \ -w /go/src/$(PACKAGE_NAME) \ goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \ -f .goreleaser.yml release --rm-dist

@troian
Copy link
Member

troian commented Apr 6, 2023

do you use custom entry point --entrypoint ./goreleaser_entry.sh ?

@troian troian closed this as completed Jul 30, 2023
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

No branches or pull requests

4 participants