Revert "feat: adding workflow_dispatch webhook event" (#879)
This reverts commit d36d47fe66.
This commit is contained in:
parent
d36d47fe66
commit
5805e39e1f
|
|
@ -69,10 +69,9 @@ type ScaleUpTrigger struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type GitHubEventScaleUpTriggerSpec struct {
|
type GitHubEventScaleUpTriggerSpec struct {
|
||||||
CheckRun *CheckRunSpec `json:"checkRun,omitempty"`
|
CheckRun *CheckRunSpec `json:"checkRun,omitempty"`
|
||||||
PullRequest *PullRequestSpec `json:"pullRequest,omitempty"`
|
PullRequest *PullRequestSpec `json:"pullRequest,omitempty"`
|
||||||
Push *PushSpec `json:"push,omitempty"`
|
Push *PushSpec `json:"push,omitempty"`
|
||||||
WorkflowDispatch *WorkflowDispatchSpec `json:"push,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://docs.github.com/en/actions/reference/events-that-trigger-workflows#check_run
|
// https://docs.github.com/en/actions/reference/events-that-trigger-workflows#check_run
|
||||||
|
|
@ -102,13 +101,6 @@ type PullRequestSpec struct {
|
||||||
type PushSpec struct {
|
type PushSpec struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// WorkflowDispatchSpec is the condition for triggering scale-up on push event
|
|
||||||
// Also see https://docs.github.com/en/actions/reference/events-that-trigger-workflows#workflow_dispatch
|
|
||||||
type WorkflowDispatchSpec struct {
|
|
||||||
Branches []string `json:"branches,omitempty"`
|
|
||||||
BranchesIgnore []string `json:"branchesIgnore,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// CapacityReservation specifies the number of replicas temporarily added
|
// CapacityReservation specifies the number of replicas temporarily added
|
||||||
// to the scale target until ExpirationTime.
|
// to the scale target until ExpirationTime.
|
||||||
type CapacityReservation struct {
|
type CapacityReservation struct {
|
||||||
|
|
|
||||||
|
|
@ -157,18 +157,6 @@ spec:
|
||||||
push:
|
push:
|
||||||
description: PushSpec is the condition for triggering scale-up on push event Also see https://docs.github.com/en/actions/reference/events-that-trigger-workflows#push
|
description: PushSpec is the condition for triggering scale-up on push event Also see https://docs.github.com/en/actions/reference/events-that-trigger-workflows#push
|
||||||
type: object
|
type: object
|
||||||
workflowDispatch:
|
|
||||||
description: WorkflowDispatchSpec is the condition for triggering scale-up on workflow_dispatch event Also see https://docs.github.com/en/actions/reference/events-that-trigger-workflows#workflow_dispatch
|
|
||||||
properties:
|
|
||||||
branches:
|
|
||||||
items:
|
|
||||||
type: string
|
|
||||||
type: array
|
|
||||||
branchesIgnore:
|
|
||||||
items:
|
|
||||||
type: string
|
|
||||||
type: array
|
|
||||||
type: object
|
|
||||||
type: object
|
type: object
|
||||||
type: object
|
type: object
|
||||||
type: array
|
type: array
|
||||||
|
|
|
||||||
|
|
@ -183,15 +183,6 @@ func (autoscaler *HorizontalRunnerAutoscalerGitHubWebhook) Handle(w http.Respons
|
||||||
"action", e.GetAction(),
|
"action", e.GetAction(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
case *gogithub.WorkflowDispatchEvent:
|
|
||||||
target, err = autoscaler.getScaleUpTarget(
|
|
||||||
context.TODO(),
|
|
||||||
log,
|
|
||||||
e.Repo.GetName(),
|
|
||||||
e.Repo.Owner.GetLogin(),
|
|
||||||
e.Repo.Owner.GetType(),
|
|
||||||
autoscaler.WorkflowDispatchEvent(e),
|
|
||||||
)
|
|
||||||
case *gogithub.WorkflowJobEvent:
|
case *gogithub.WorkflowJobEvent:
|
||||||
if workflowJob := e.GetWorkflowJob(); workflowJob != nil {
|
if workflowJob := e.GetWorkflowJob(); workflowJob != nil {
|
||||||
log = log.WithValues(
|
log = log.WithValues(
|
||||||
|
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
package controllers
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/actions-runner-controller/actions-runner-controller/api/v1alpha1"
|
|
||||||
"github.com/google/go-github/v37/github"
|
|
||||||
)
|
|
||||||
|
|
||||||
// MatchPushEvent()
|
|
||||||
func (autoscaler *HorizontalRunnerAutoscalerGitHubWebhook) MatchWorkflowDispatchEvent(event *github.PushEvent) func(scaleUpTrigger v1alpha1.ScaleUpTrigger) bool {
|
|
||||||
return func(scaleUpTrigger v1alpha1.ScaleUpTrigger) bool {
|
|
||||||
g := scaleUpTrigger.GitHubEvent
|
|
||||||
|
|
||||||
if g == nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
WorkflowDispatch := g.WorkflowDispatch
|
|
||||||
|
|
||||||
if WorkflowDispatch == nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// event.Ref = Branch that received dispatch
|
|
||||||
// event.Ref = refs/heads/branch-name
|
|
||||||
if !matchTriggerConditionAgainstEvent(WorkflowDispatch.Branches, event.Ref) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
if matchTriggerConditionAgainstEvent(WorkflowDispatch.BranchesIgnore, event.Ref) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue