From a94498b482758d8519ca001b2d9e507afd50df11 Mon Sep 17 00:00:00 2001 From: a1012112796 <1012112796@qq.com> Date: Tue, 13 Jun 2023 03:46:26 +0000 Subject: [PATCH] fix local workflow for `act_runner exec` (#63) by the way, export `ACT_SKIP_CHECKOUT` as a env verb for user to do some special config of local test. example usage: https://github.com/a1012112796/gitea/commit/7a3ab0fdbc351b96861a49ba24c59056946c7909 Reviewed-on: https://gitea.com/gitea/act/pulls/63 Reviewed-by: Jason Song <i@wolfogre.com> Co-authored-by: a1012112796 <1012112796@qq.com> Co-committed-by: a1012112796 <1012112796@qq.com> --- pkg/runner/reusable_workflow.go | 12 ++++++++++++ pkg/runner/run_context.go | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/pkg/runner/reusable_workflow.go b/pkg/runner/reusable_workflow.go index 2e97bdf..e9c7bbe 100644 --- a/pkg/runner/reusable_workflow.go +++ b/pkg/runner/reusable_workflow.go @@ -17,6 +17,18 @@ import ( ) func newLocalReusableWorkflowExecutor(rc *RunContext) common.Executor { + if !rc.Config.NoSkipCheckout { + fullPath := rc.Run.Job().Uses + + fileName := path.Base(fullPath) + workflowDir := strings.TrimSuffix(fullPath, path.Join("/", fileName)) + workflowDir = strings.TrimPrefix(workflowDir, "./") + + return common.NewPipelineExecutor( + newReusableWorkflowExecutor(rc, workflowDir, fileName), + ) + } + // ./.gitea/workflows/wf.yml -> .gitea/workflows/wf.yml trimmedUses := strings.TrimPrefix(rc.Run.Job().Uses, "./") // uses string format is {owner}/{repo}/.{git_platform}/workflows/{filename}@{ref} diff --git a/pkg/runner/run_context.go b/pkg/runner/run_context.go index 13b0765..898e47a 100644 --- a/pkg/runner/run_context.go +++ b/pkg/runner/run_context.go @@ -82,6 +82,11 @@ func (rc *RunContext) GetEnv() map[string]string { } } rc.Env["ACT"] = "true" + + if !rc.Config.NoSkipCheckout { + rc.Env["ACT_SKIP_CHECKOUT"] = "true" + } + return rc.Env }