1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-09-15 18:57:01 +00:00

fix: use a token to clone a URL when relevant

Refs https://codeberg.org/forgejo/forgejo/pulls/8808
This commit is contained in:
Earl Warren 2025-08-07 07:30:00 +02:00
parent 96891ab314
commit 9bbfab5d47
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
2 changed files with 11 additions and 10 deletions

View file

@ -213,3 +213,10 @@ func (ghc *GithubContext) SetBaseAndHeadRef() {
} }
} }
} }
func (ghc *GithubContext) GetToken(url string) string {
if url != ghc.ServerURL {
return ""
}
return ghc.Token
}

View file

@ -112,13 +112,7 @@ func (sar *stepActionRemote) prepareActionExecutor() common.Executor {
URL: sar.remoteAction.CloneURL(sar.RunContext.Config.DefaultActionInstance), URL: sar.remoteAction.CloneURL(sar.RunContext.Config.DefaultActionInstance),
Ref: sar.remoteAction.Ref, Ref: sar.remoteAction.Ref,
Dir: actionDir, Dir: actionDir,
Token: "", /* Token: github.GetToken(sar.remoteAction.URL),
Shouldn't provide token when cloning actions,
the token comes from the instance which triggered the task,
however, it might be not the same instance which provides actions.
For GitHub, they are the same, always github.com.
But for Gitea, tasks triggered by a.com can clone actions from b.com.
*/
OfflineMode: sar.RunContext.Config.ActionOfflineMode, OfflineMode: sar.RunContext.Config.ActionOfflineMode,
InsecureSkipTLS: sar.cloneSkipTLS(), // For Gitea InsecureSkipTLS: sar.cloneSkipTLS(), // For Gitea