diff --git a/act/runner/reusable_workflow.go b/act/runner/reusable_workflow.go index 3a805b0a..2fa5d013 100644 --- a/act/runner/reusable_workflow.go +++ b/act/runner/reusable_workflow.go @@ -35,7 +35,7 @@ func newLocalReusableWorkflowExecutor(rc *RunContext) common.Executor { // uses string format is {owner}/{repo}/.{git_platform}/workflows/{filename}@{ref} uses := fmt.Sprintf("%s/%s@%s", rc.Config.PresetGitHubContext.Repository, trimmedUses, rc.Config.PresetGitHubContext.Sha) - remoteReusableWorkflow := newRemoteReusableWorkflowWithPlat(rc.Config.GitHubInstance, uses) + remoteReusableWorkflow := newRemoteReusableWorkflowWithPlat(uses) if remoteReusableWorkflow == nil { return common.NewErrorExecutor(fmt.Errorf("expected format {owner}/{repo}/.{git_platform}/workflows/{filename}@{ref}. Actual '%s' Input string was not in a correct format", uses)) } @@ -54,7 +54,7 @@ func newLocalReusableWorkflowExecutor(rc *RunContext) common.Executor { func newRemoteReusableWorkflowExecutor(rc *RunContext) common.Executor { uses := rc.Run.Job().Uses - remoteReusableWorkflow := newRemoteReusableWorkflowWithPlat(rc.Config.GitHubInstance, uses) + remoteReusableWorkflow := newRemoteReusableWorkflowWithPlat(uses) if remoteReusableWorkflow == nil { return common.NewErrorExecutor(fmt.Errorf("expected format {owner}/{repo}/.{git_platform}/workflows/{filename}@{ref}. Actual '%s' Input string was not in a correct format", uses)) } @@ -203,23 +203,22 @@ func (r *remoteReusableWorkflow) FilePath() string { return fmt.Sprintf("./.%s/workflows/%s", r.GitPlatform, r.Filename) } -// For Gitea // newRemoteReusableWorkflowWithPlat create a `remoteReusableWorkflow` -// workflows from `.gitea/workflows` and `.github/workflows` are supported -func newRemoteReusableWorkflowWithPlat(url, uses string) *remoteReusableWorkflow { +// workflows matching `**/workflows/*@*` are supported +func newRemoteReusableWorkflowWithPlat(uses string) *remoteReusableWorkflow { // GitHub docs: // https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_iduses - r := regexp.MustCompile(`^([^/]+)/([^/]+)/\.([^/]+)/workflows/([^@]+)@(.*)$`) + r := regexp.MustCompile(`^(.*)/([^/]+)/([^/]+)/\.([^/]+)/workflows/([^@]+)@(.*)$`) matches := r.FindStringSubmatch(uses) - if len(matches) != 6 { + if len(matches) != 7 { return nil } return &remoteReusableWorkflow{ - Org: matches[1], - Repo: matches[2], - GitPlatform: matches[3], - Filename: matches[4], - Ref: matches[5], - URL: url, + URL: matches[1], + Org: matches[2], + Repo: matches[3], + GitPlatform: matches[4], + Filename: matches[5], + Ref: matches[6], } }