-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Support actions and reusable workflows from private repos #32562
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
base: main
Are you sure you want to change the base?
Conversation
For changes in |
Is this related to #24635 ? |
Any progress for it? |
Any progress there? |
Any movement here? This would really really help us in our Gitea Cloud account. |
|
01211b3
to
82d368c
Compare
203ad9c
to
01035bd
Compare
Co-authored-by: ChristopherHX <christopher.homberger@web.de> Signed-off-by: Zettat123 <zettat123@gmail.com>
Related to go-gitea/gitea#32562 Resolve https://gitea.com/gitea/act_runner/issues/102 To support using actions and workflows from private repositories, we need to enable act_runner to clone private repositories. ~~But it is not easy to know if a repository is private and whether a token is required when cloning. In this PR, I added a new option `RetryToken`. By default, token is empty. When cloning a repo returns an `authentication required` error, `act_runner` will try to clone the repo again using `RetryToken` as the token.~~ In this PR, I added a new `getGitCloneToken` function. This function returns `GITEA_TOKEN` for cloning remote actions or remote reusable workflows when the cloneURL is from the same Gitea instance that the runner is registered to. Otherwise, it returns an empty string as token for cloning public repos from other instances (such as GitHub). Thanks @ChristopherHX for https://gitea.com/gitea/act/pulls/123#issuecomment-1046171 and https://gitea.com/gitea/act/pulls/123#issuecomment-1046285. Reviewed-on: https://gitea.com/gitea/act/pulls/123 Reviewed-by: ChristopherHX <christopherhx@noreply.gitea.com> Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Zettat123 <zettat123@gmail.com> Co-committed-by: Zettat123 <zettat123@gmail.com>
I think we should rewrite Lines 198 to 201 in 38dd432
My expectation was, I can use gitea.token to clone any public repository from my gitea instance. However I was wrong and we didn't seem to had any test on act_runner side to prevent the act change from merge. |
Found duplicated permission checks in Lines 191 to 214 in ebd88af
Maybe those should use a common function, githttp access and no api access is odd. |
Then lfs again, 3 times same code Lines 523 to 537 in ebd88af
See here for my proposal: #35688, then only a single method decides wether and what level you can access an repository via an actions token |
Signed-off-by: Zettat123 <zettat123@gmail.com>
if task.RepoID != repo.ID { | ||
taskRepo, exist, err := db.GetByID[repo_model.Repository](ctx, task.RepoID) | ||
if err != nil || !exist { | ||
return perm, err | ||
} | ||
actionsCfg := repo.MustGetUnit(ctx, unit.TypeActions).ActionsConfig() | ||
if !actionsCfg.IsCollaborativeOwner(taskRepo.OwnerID) || !taskRepo.IsPrivate { | ||
// The task repo can access the current repo only if the task repo is private and | ||
// the owner of the task repo is a collaborative owner of the current repo. | ||
// FIXME allow public repo read access if tokenless pull is enabled | ||
return perm, nil | ||
} | ||
accessMode = perm_model.AccessModeRead | ||
} else if task.IsForkPullRequest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please double check this change, migrated your permission check.
This feels like we need action token tests for this as well, not only api manage tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the change, I think it looks good.
I updated the test, please review:
Resolve https://gitea.com/gitea/act_runner/issues/102
This PR allows administrators of a private repository to specify some collaborative owners. The repositories of collaborative owners will be allowed to access this repository's actions and workflows.
Settings for private repos:
This PR also moves "Enable Actions" setting to
Actions > General
page