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

actions/checkout fails to retrieve default branch name #29654

Open
nyanotech opened this issue Mar 8, 2024 · 9 comments · May be fixed by #32572
Open

actions/checkout fails to retrieve default branch name #29654

nyanotech opened this issue Mar 8, 2024 · 9 comments · May be fixed by #32572
Labels
issue/workaround it is or has a workaround topic/api Concerns mainly the API topic/gitea-actions related to the actions of Gitea

Comments

@nyanotech
Copy link

Description

I have a private repo, with an actions workflow that uses actions/checkout (I've tried v3 and v4, both have this issue) to check out first itself, and then a different private repo, like this.

When I run this, the action fails with this error:

::group::Determining the default branch
Retrieving the default branch name
Not found.

Looking through the logs on the gitea side, I find:

2024/03/06 02:48:38 ...eb/routing/logger.go:102:func1() [I] router: completed GET /api/v3/repos/[user]/[repo] for 10.89.0.2:0, 404 Not Found in 20.3ms @ web/goget.go:20(web.goGet)

Looking in the swagger ui, it looks like the base url is at /api/v1, so I assume that a v3 version of the route is just nonexistent.

In the end, I was able to work around this issue by manually specifying a ref: master to check out in the action's config, and that let the rest of the checkout succeed.

I'm having some trouble signing up on try.gitea.io at the moment, but I'll set up a repro on there when I get a chance.

Gitea Version

1.21.7

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

2.43.1

Operating System

linux (nixos unstable)

How are you running Gitea?

gitea via nixos's package (runs under systemd, no containers), behind a nginx reverse proxy.

gitea instance is under its own subdomain, no extra subdir that it lives under.

the actions runner is also installed via nixos's package manager, running under systemd, on the same box

Database

PostgreSQL

@nyanotech nyanotech changed the title actions/checkout retrieve default branch name actions/checkout fails to retrieve default branch name Mar 8, 2024
@yp05327
Copy link
Contributor

yp05327 commented Mar 8, 2024

It seems that GHES only have v3 for APIs, and it is hard coded in checkout.
So maybe it is hard to push a PR for supporting custom API versions in checkout.

@a1012112796
Copy link
Member

looks a quick fix option is seting ref input, example:

      - name: Checkout tools repo
        uses: actions/checkout@v4
        with:
          repository: testa/test_1
          path: my-tools
+         ref: main

@nyanotech
Copy link
Author

Yeah, that's what I ended up doing on the repo where I ran into this.

@yp05327
Copy link
Contributor

yp05327 commented Mar 8, 2024

Yeah, checkout will get default branch by using API, if you provided one, then there's no need to get it from API.
see:
https://github.com/actions/checkout/blob/8eb1f6a495037164bea451156472f35fdd6bafc0/src/git-source-provider.ts#L134

@a1012112796 a1012112796 added type/proposal The new feature has not been accepted yet but needs to be discussed first. topic/gitea-actions related to the actions of Gitea and removed type/bug labels Mar 8, 2024
@silverwind
Copy link
Member

silverwind commented Mar 8, 2024

#29676 is closely related and I think the best course of action is to implement this API shim for that one /v3/repos/ API. The subsequent two API-calls (download zip or tar.gz) after it will likely already work.

@silverwind silverwind added the topic/api Concerns mainly the API label Mar 8, 2024
@silverwind
Copy link
Member

silverwind commented Mar 8, 2024

I closed #29676 in favor of this one. Basically we need to implement these APIs (the latter two likely already exist):

  • GET /api/v3/repos/{owner}/{repo}
  • GET /repos/{owner}/{repo}/tarball/{ref}
  • GET /repos/{owner}/{repo}/zipball/{ref}

Relevant actions/checkout code is here. It's activated when git is not present in the image.

@silverwind silverwind removed the type/proposal The new feature has not been accepted yet but needs to be discussed first. label Mar 8, 2024
@nyanotech
Copy link
Author

nyanotech commented Mar 8, 2024

I think it's also called if neither ref nor commit are specified, even if git is present: https://github.com/actions/checkout/blob/8eb1f6a495037164bea451156472f35fdd6bafc0/src/git-source-provider.ts#L139

@Byorun
Copy link

Byorun commented Sep 28, 2024

I closed #29676 in favor of this one. Basically we need to implement these APIs (the latter two likely already exist):

  • GET /api/v3/repos/{owner}/{repo}
  • GET /repos/{owner}/{repo}/tarball/{ref}
  • GET /repos/{owner}/{repo}/zipball/{ref}

Relevant actions/checkout code is here. It's activated when git is not present in the image.

I am fairly new to gitea actions, but I am also running into this because (by design) didn't include git in my image. As long as the checkout action tries to download the archive from this non existing api endpoints i am forced to include git in my images or scrap gitea actions alltogether which would be sad

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue/workaround it is or has a workaround topic/api Concerns mainly the API topic/gitea-actions related to the actions of Gitea
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants