ghactions

package module
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: Apache-2.0 Imports: 7 Imported by: 5

README

GHActions

GitHub tag (latest SemVer) Build Status PkgGoDev

Sponsor

Create a GitHub Action in 5 seconds!

Examples

package main

import (
	"context"
	"log"

	"github.com/google/go-github/v49/github"
	"github.com/ldez/ghactions"
	"github.com/ldez/ghactions/event"
)

func main() {
	ctx := context.Background()
	action := ghactions.NewAction(ctx)
	// action.SkipWhenNoHandler = true
	// action.SkipWhenTypeUnknown = true

	err := action.
		OnPullRequest(func(client *github.Client, requestEvent *github.PullRequestEvent) error {
			// TODO add your code.
			return nil
		}).
		OnIssues(func(client *github.Client, issuesEvent *github.IssuesEvent) error {
			// TODO add your code.
			return nil
		}).
		Run()

	if err != nil {
		log.Fatal(err)
	}
}

References

Documentation

Overview

Package ghactions Creates a GitHub Actions in 5s.

Index

Constants

View Source
const (
	Home             = "HOME"
	Hostname         = "HOSTNAME"
	PWD              = "PWD"
	Path             = "PATH"
	GithubAction     = "GITHUB_ACTION"
	GithubActions    = "GITHUB_ACTIONS"
	GithubActor      = "GITHUB_ACTOR"
	GithubToken      = "GITHUB_TOKEN"
	GithubWorkflow   = "GITHUB_WORKFLOW"
	GithubRunID      = "GITHUB_RUN_ID"
	GithubRunNumber  = "GITHUB_RUN_NUMBER"
	GithubRepository = "GITHUB_REPOSITORY"
	GithubEventName  = "GITHUB_EVENT_NAME"
	GithubEventPath  = "GITHUB_EVENT_PATH"
	GithubWorkspace  = "GITHUB_WORKSPACE"
	GithubSha        = "GITHUB_SHA"
	GithubRef        = "GITHUB_REF"
	GithubHeadRef    = "GITHUB_HEAD_REF"
	GithubBaseRef    = "GITHUB_BASE_REF"
)

GitHub Action environment variables.

Variables

This section is empty.

Functions

func GetRepoInfo

func GetRepoInfo() (owner, repoName string)

GetRepoInfo Split "GITHUB_REPOSITORY" to [owner, repoName].

Types

type Action

type Action struct {
	SkipWhenNoHandler   bool
	SkipWhenTypeUnknown bool
	// contains filtered or unexported fields
}

Action GitHub Action executor.

func NewAction

func NewAction(ctx context.Context) *Action

NewAction Creates a new GitHub Action executor.

func (*Action) OnCheckRun added in v1.2.0

func (a *Action) OnCheckRun(eventHandler func(*github.Client, *github.CheckRunEvent) error) *Action

OnCheckRun CheckRun handler.

func (*Action) OnCheckSuite added in v1.2.0

func (a *Action) OnCheckSuite(eventHandler func(*github.Client, *github.CheckSuiteEvent) error) *Action

OnCheckSuite CheckSuite handler.

func (*Action) OnCommitComment

func (a *Action) OnCommitComment(eventHandler func(*github.Client, *github.CommitCommentEvent) error) *Action

OnCommitComment CommitComment handler.

func (*Action) OnCreate

func (a *Action) OnCreate(eventHandler func(*github.Client, *github.CreateEvent) error) *Action

OnCreate Create handler.

func (*Action) OnDelete

func (a *Action) OnDelete(eventHandler func(*github.Client, *github.DeleteEvent) error) *Action

OnDelete Delete handler.

func (*Action) OnDeployment

func (a *Action) OnDeployment(eventHandler func(*github.Client, *github.DeploymentEvent) error) *Action

OnDeployment Deployment handler.

func (*Action) OnDeploymentStatus

func (a *Action) OnDeploymentStatus(eventHandler func(*github.Client, *github.DeploymentStatusEvent) error) *Action

OnDeploymentStatus DeploymentStatus handler.

func (*Action) OnFork

func (a *Action) OnFork(eventHandler func(*github.Client, *github.ForkEvent) error) *Action

OnFork Fork handler.

func (*Action) OnGollum

func (a *Action) OnGollum(eventHandler func(*github.Client, *github.GollumEvent) error) *Action

OnGollum Gollum handler.

func (*Action) OnIssueComment

func (a *Action) OnIssueComment(eventHandler func(*github.Client, *github.IssueCommentEvent) error) *Action

OnIssueComment IssueComment handler.

func (*Action) OnIssues

func (a *Action) OnIssues(eventHandler func(*github.Client, *github.IssuesEvent) error) *Action

OnIssues Issues handler.

func (*Action) OnLabel

func (a *Action) OnLabel(eventHandler func(*github.Client, *github.LabelEvent) error) *Action

OnLabel Label handler.

func (*Action) OnMember

func (a *Action) OnMember(eventHandler func(*github.Client, *github.MemberEvent) error) *Action

OnMember Member handler.

func (*Action) OnMilestone

func (a *Action) OnMilestone(eventHandler func(*github.Client, *github.MilestoneEvent) error) *Action

OnMilestone Milestone handler.

func (*Action) OnPageBuild

func (a *Action) OnPageBuild(eventHandler func(*github.Client, *github.PageBuildEvent) error) *Action

OnPageBuild PageBuild handler.

func (*Action) OnProject

func (a *Action) OnProject(eventHandler func(*github.Client, *github.ProjectEvent) error) *Action

OnProject Project handler.

func (*Action) OnProjectCard

func (a *Action) OnProjectCard(eventHandler func(*github.Client, *github.ProjectCardEvent) error) *Action

OnProjectCard ProjectCard handler.

func (*Action) OnProjectColumn

func (a *Action) OnProjectColumn(eventHandler func(*github.Client, *github.ProjectColumnEvent) error) *Action

OnProjectColumn ProjectColumn handler.

func (*Action) OnPublic

func (a *Action) OnPublic(eventHandler func(*github.Client, *github.PublicEvent) error) *Action

OnPublic Public handler.

func (*Action) OnPullRequest

func (a *Action) OnPullRequest(eventHandler func(*github.Client, *github.PullRequestEvent) error) *Action

OnPullRequest PullRequest handler.

func (*Action) OnPullRequestReview

func (a *Action) OnPullRequestReview(eventHandler func(*github.Client, *github.PullRequestReviewEvent) error) *Action

OnPullRequestReview PullRequestReview handler.

func (*Action) OnPullRequestReviewComment

func (a *Action) OnPullRequestReviewComment(eventHandler func(*github.Client, *github.PullRequestReviewCommentEvent) error) *Action

OnPullRequestReviewComment PullRequestReviewComment handler.

func (*Action) OnPullRequestTarget added in v1.5.0

func (a *Action) OnPullRequestTarget(eventHandler func(*github.Client, *github.PullRequestTargetEvent) error) *Action

OnPullRequestTarget PullRequestTarget handler.

func (*Action) OnPush

func (a *Action) OnPush(eventHandler func(*github.Client, *github.PushEvent) error) *Action

OnPush Push handler.

func (*Action) OnRelease

func (a *Action) OnRelease(eventHandler func(*github.Client, *github.ReleaseEvent) error) *Action

OnRelease Release handler.

func (*Action) OnRepositoryVulnerabilityAlert

func (a *Action) OnRepositoryVulnerabilityAlert(eventHandler func(*github.Client, *github.RepositoryVulnerabilityAlertEvent) error) *Action

OnRepositoryVulnerabilityAlert RepositoryVulnerabilityAlert handler.

func (*Action) OnStatus

func (a *Action) OnStatus(eventHandler func(*github.Client, *github.StatusEvent) error) *Action

OnStatus Status handler.

func (*Action) OnWatch

func (a *Action) OnWatch(eventHandler func(*github.Client, *github.WatchEvent) error) *Action

OnWatch Watch handler.

func (*Action) Run

func (a *Action) Run() error

Run Executes action.

Jump to

Keyboard shortcuts

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