action

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 29, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FuncRequired = errors.New("action func is required")
)

Functions

This section is empty.

Types

type Action

type Action interface {
	Do() error
}

func New

func New(f ActionFunc) (Action, error)

type ActionFunc

type ActionFunc = func(ctx *Context) error

type Context

type Context struct {
	Repository string `json:"repo", env:"GITHUB_REPOSITORY"`
	SHA        string `json:"sha" env:"GITHUB_SHA"`
	Ref        string `json:"ref" env:"GITHUB_REF"`
	EventName  string `json:"eventName" env:"GITHUB_EVENT_NAME"`
	Workflow   string `json:"workflow" env:"GITHUB_WORKFLOW"`
	Action     string `json:"action" env:"GITHUB_ACTION"`
	Actor      string `json:"actor" env:"GITHUB_ACTOR"`
	Job        string `json:"job" env:"GITHUB_JOB"`
	RunNumber  int    `json:"runNumber" env:"GITHUB_RUN_NUMBER"`
	RunID      int    `json:"runID" env:"GITHUB_RUN_ID"`
	ApiURL     string `json:"apiUrl" env:"GITHUB_API_URL" envDefault:"ttps://api.github.com"`
	ServerURL  string `json:"serverUrl" env:"GITHUB_SERVER_URL" envDefault:"https://github.com"`
	GraphQLUrl string `json:"graphqlUrl" env:"GITHUB_GRAPHQL_URL " envDefault:"https://api.github.com/graphql"`
	Event      *Event `json:"payload"`
	EventPath  string `env:"GITHUB_EVENT_PATH"`
}

func NewContextFromEnv

func NewContextFromEnv() (*Context, error)

type Event

type Event struct {
	Action string `json:"action"`
	After  string `json:"after"`
	Before string `json:"before"`
	Number int    `json:"number"`

	PullRequest *PullRequest `json:"pull_request"`
}

type PullRequest

type PullRequest struct {
	Body         string    `json:"body"`
	ChangedFiles int       `json:"changed_files"`
	Commits      int       `json:"commits"`
	CreatedAt    time.Time `json:"created_at"`
	Draft        bool      `json:"draft"`
	HtmlURL      string    `json:"html_url"`
	ID           int       `json:"id"`
	//Labels       []string  `json:"labels,omitempty"`
	Number int    `json:"number"`
	Title  string `json:"title"`
}

PullRequest represents the payload for a pull request GitHub Actions event NOTE: not all the fields have been added

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL