actions/checkout fails to retrieve default branch name #12610

Closed
opened 2025-11-02 10:15:59 -06:00 by GiteaMirror · 9 comments
Owner

Originally created by @nyanotech on GitHub (Mar 8, 2024).

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

Originally created by @nyanotech on GitHub (Mar 8, 2024). ### 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](https://gitea.com/actions/checkout#checkout-multiple-repos-private). 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
GiteaMirror added the topic/apitopic/gitea-actionsissue/workaround labels 2025-11-02 10:15:59 -06:00
Author
Owner

@yp05327 commented on GitHub (Mar 8, 2024):

8eb1f6a495/src/url-helper.ts (L35)

@yp05327 commented on GitHub (Mar 8, 2024): https://github.com/actions/checkout/blob/8eb1f6a495037164bea451156472f35fdd6bafc0/src/url-helper.ts#L35
Author
Owner

@yp05327 commented on GitHub (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.

@yp05327 commented on GitHub (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.
Author
Owner

@a1012112796 commented on GitHub (Mar 8, 2024):

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
@a1012112796 commented on GitHub (Mar 8, 2024): looks a quick fix option is seting `ref` input, example: ```DIFF - name: Checkout tools repo uses: actions/checkout@v4 with: repository: testa/test_1 path: my-tools + ref: main ```
Author
Owner

@nyanotech commented on GitHub (Mar 8, 2024):

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

@nyanotech commented on GitHub (Mar 8, 2024): Yeah, that's what I ended up doing on the repo where I ran into this.
Author
Owner

@yp05327 commented on GitHub (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:
8eb1f6a495/src/git-source-provider.ts (L134)

@yp05327 commented on GitHub (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
Author
Owner

@silverwind commented on GitHub (Mar 8, 2024):

https://github.com/go-gitea/gitea/issues/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 commented on GitHub (Mar 8, 2024): https://github.com/go-gitea/gitea/issues/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.
Author
Owner

@silverwind commented on GitHub (Mar 8, 2024):

I closed https://github.com/go-gitea/gitea/issues/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 commented on GitHub (Mar 8, 2024): I closed https://github.com/go-gitea/gitea/issues/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. - https://github.com/actions/checkout/blob/8eb1f6a495037164bea451156472f35fdd6bafc0/src/git-source-provider.ts#L74 - https://github.com/actions/checkout/blob/8eb1f6a495037164bea451156472f35fdd6bafc0/src/github-api-helper.ts#L26
Author
Owner

@nyanotech commented on GitHub (Mar 8, 2024):

I think it's also called if neither ref nor commit are specified, even if git is present: 8eb1f6a495/src/git-source-provider.ts (L139)

@nyanotech commented on GitHub (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
Author
Owner

@Byorun commented on GitHub (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

@Byorun commented on GitHub (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. > > * https://github.com/actions/checkout/blob/8eb1f6a495037164bea451156472f35fdd6bafc0/src/git-source-provider.ts#L74 > * https://github.com/actions/checkout/blob/8eb1f6a495037164bea451156472f35fdd6bafc0/src/github-api-helper.ts#L26 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 in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#12610