1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-10-15 19:42:06 +00:00

pin to v1.0.0 of github action parser

This commit is contained in:
Casey Lee 2019-02-06 22:36:08 -08:00
parent 9c3a288946
commit eb25b2a615
116 changed files with 9431 additions and 3576 deletions

View file

@ -1,5 +1,9 @@
package model
import (
"strings"
)
// Configuration is a parsed main.workflow file
type Configuration struct {
Actions []*Action
@ -52,7 +56,7 @@ func (c *Configuration) GetWorkflow(id string) *Workflow {
func (c *Configuration) GetWorkflows(eventType string) []*Workflow {
var ret []*Workflow
for _, workflow := range c.Workflows {
if IsMatchingEventType(workflow.On, eventType) {
if strings.EqualFold(workflow.On, eventType) {
ret = append(ret, workflow)
}
}

View file

@ -1,55 +0,0 @@
package model
import (
"strings"
)
// IsAllowedEventType returns true if the event type is supported.
func IsAllowedEventType(eventType string) bool {
_, ok := eventTypeWhitelist[strings.ToLower(eventType)]
return ok
}
// IsMatchingEventType checks to see if the "flowOn" string from a flow's on attribute matches the incoming webhook of type eventType.
func IsMatchingEventType(flowOn, eventType string) bool {
return strings.EqualFold(flowOn, eventType)
}
// https://developer.github.com/actions/creating-workflows/workflow-configuration-options/#events-supported-in-workflow-files
var eventTypeWhitelist = map[string]struct{}{
"check_run": {},
"check_suite": {},
"commit_comment": {},
"create": {},
"delete": {},
"deployment": {},
"deployment_status": {},
"fork": {},
"gollum": {},
"issue_comment": {},
"issues": {},
"label": {},
"member": {},
"milestone": {},
"page_build": {},
"project_card": {},
"project_column": {},
"project": {},
"public": {},
"pull_request_review_comment": {},
"pull_request_review": {},
"pull_request": {},
"push": {},
"release": {},
"repository_dispatch": {},
"status": {},
"watch": {},
}
func AddAllowedEventType(s string) {
eventTypeWhitelist[s] = struct{}{}
}
func RemoveAllowedEventType(s string) {
delete(eventTypeWhitelist, s)
}