From 719a077b7c86e820a3153a8a31682c9a8541edb9 Mon Sep 17 00:00:00 2001 From: "KADOTA, Kyohei" Date: Thu, 21 Jan 2021 23:00:33 +0900 Subject: [PATCH] Stop current execution if there is the invalid syntax in the workflow (#495) --- pkg/runner/step_context.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/runner/step_context.go b/pkg/runner/step_context.go index 9faa4bc..87ba77b 100644 --- a/pkg/runner/step_context.go +++ b/pkg/runner/step_context.go @@ -57,6 +57,15 @@ func (sc *StepContext) Executor() common.Executor { ) case model.StepTypeUsesActionRemote: remoteAction := newRemoteAction(step.Uses) + if remoteAction.Ref == "" { + // GitHub's document[^] describes: + // > We strongly recommend that you include the version of + // > the action you are using by specifying a Git ref, SHA, or Docker tag number. + // Actually, the workflow stops if there is the uses directive that hasn't @ref. + // [^]: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions + msg := fmt.Sprintf("Expected format {org}/{repo}[/path]@ref. Actual '%s' Input string was not in a correct format.", step.Uses) + return common.NewErrorExecutor(fmt.Errorf("%s", msg)) + } if remoteAction.IsCheckout() && rc.getGithubContext().isLocalCheckout(step) { return func(ctx context.Context) error { common.Logger(ctx).Debugf("Skipping actions/checkout") @@ -398,8 +407,6 @@ func newRemoteAction(action string) *remoteAction { ra := new(remoteAction) ra.Org = matches[1] ra.Repo = matches[2] - ra.Path = "" - ra.Ref = "master" if len(matches) >= 5 { ra.Path = matches[4] }