1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-08-11 17:50:58 +00:00

fix #122 - support actions/checkout for repos other the one for this workflow (#143)

This commit is contained in:
Casey Lee 2020-03-09 17:45:42 -07:00 committed by GitHub
parent caba9f7645
commit e60c46b79f
4 changed files with 66 additions and 3 deletions

View file

@ -55,7 +55,7 @@ func (sc *StepContext) Executor() common.Executor {
)
case model.StepTypeUsesActionRemote:
remoteAction := newRemoteAction(step.Uses)
if remoteAction.Org == "actions" && remoteAction.Repo == "checkout" {
if remoteAction.IsCheckout() && rc.getGithubContext().isLocalCheckout(step) {
return func(ctx context.Context) error {
common.Logger(ctx).Debugf("Skipping actions/checkout")
return nil
@ -232,7 +232,7 @@ func (sc *StepContext) runAction(actionDir string, actionPath string) common.Exe
envKey := regexp.MustCompile("[^A-Z0-9-]").ReplaceAllString(strings.ToUpper(inputID), "_")
envKey = fmt.Sprintf("INPUT_%s", envKey)
if _, ok := sc.Env[envKey]; !ok {
sc.Env[envKey] = input.Default
sc.Env[envKey] = rc.ExprEval.Interpolate(input.Default)
}
}
@ -311,6 +311,13 @@ func (ra *remoteAction) CloneURL() string {
return fmt.Sprintf("https://github.com/%s/%s", ra.Org, ra.Repo)
}
func (ra *remoteAction) IsCheckout() bool {
if ra.Org == "actions" && ra.Repo == "checkout" {
return true
}
return false
}
func newRemoteAction(action string) *remoteAction {
r := regexp.MustCompile(`^([^/@]+)/([^/@]+)(/([^@]*))?(@(.*))?$`)
matches := r.FindStringSubmatch(action)