mirror of
				https://gitea.com/gitea/act_runner.git
				synced 2025-11-03 22:28:55 +01:00 
			
		
		
		
	feat: support github mirror (#716)
ref: https://github.com/go-gitea/gitea/issues/34858
when github_mirror='https://ghfast.top/https://github.com'
it will clone from the github mirror
However, there is an exception: because the cache is hashed using the string, if the same cache has been used before, it will still be pulled from github, only for the newly deployed act_ruuner
In the following two scenarios, it will solve the problem encountered:
1. some github mirror is  https://xxx.com/https://github.com/actions/checkout@v4, it will report error `Expected format {org}/{repo}[/path]@ref. Actual ‘https://xxx.com/https://github.com/actions/checkout@v4’ Input string was not in a correct format`
2. If I use an action that has a dependency on another action, even if I configure the url of the action I want to use, the action that the action introduces will still pull from github.
for example 02882cc2d9/action.yml (L127-L132)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/gitea/act_runner/pulls/716
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Akkuman <akkumans@qq.com>
Co-committed-by: Akkuman <akkumans@qq.com>
			
			
This commit is contained in:
		@@ -113,6 +113,17 @@ func (r *Runner) Run(ctx context.Context, task *runnerv1.Task) error {
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// getDefaultActionsURL
 | 
			
		||||
// when DEFAULT_ACTIONS_URL == "https://github.com" and GithubMirror is not blank,
 | 
			
		||||
// it should be set to GithubMirror first.
 | 
			
		||||
func (r *Runner) getDefaultActionsURL(ctx context.Context, task *runnerv1.Task) string {
 | 
			
		||||
	giteaDefaultActionsURL := task.Context.Fields["gitea_default_actions_url"].GetStringValue()
 | 
			
		||||
	if giteaDefaultActionsURL == "https://github.com" && r.cfg.Runner.GithubMirror != "" {
 | 
			
		||||
		return r.cfg.Runner.GithubMirror
 | 
			
		||||
	}
 | 
			
		||||
	return giteaDefaultActionsURL
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (r *Runner) run(ctx context.Context, task *runnerv1.Task, reporter *report.Reporter) (err error) {
 | 
			
		||||
	defer func() {
 | 
			
		||||
		if r := recover(); r != nil {
 | 
			
		||||
@@ -137,7 +148,7 @@ func (r *Runner) run(ctx context.Context, task *runnerv1.Task, reporter *report.
 | 
			
		||||
	taskContext := task.Context.Fields
 | 
			
		||||
 | 
			
		||||
	log.Infof("task %v repo is %v %v %v", task.Id, taskContext["repository"].GetStringValue(),
 | 
			
		||||
		taskContext["gitea_default_actions_url"].GetStringValue(),
 | 
			
		||||
		r.getDefaultActionsURL(ctx, task),
 | 
			
		||||
		r.client.Address())
 | 
			
		||||
 | 
			
		||||
	preset := &model.GithubContext{
 | 
			
		||||
@@ -211,7 +222,7 @@ func (r *Runner) run(ctx context.Context, task *runnerv1.Task, reporter *report.
 | 
			
		||||
		ContainerOptions:      r.cfg.Container.Options,
 | 
			
		||||
		ContainerDaemonSocket: r.cfg.Container.DockerHost,
 | 
			
		||||
		Privileged:            r.cfg.Container.Privileged,
 | 
			
		||||
		DefaultActionInstance: taskContext["gitea_default_actions_url"].GetStringValue(),
 | 
			
		||||
		DefaultActionInstance: r.getDefaultActionsURL(ctx, task),
 | 
			
		||||
		PlatformPicker:        r.labels.PickPlatform,
 | 
			
		||||
		Vars:                  task.Vars,
 | 
			
		||||
		ValidVolumes:          r.cfg.Container.ValidVolumes,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user