ghactions

package module
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 7 Imported by: 5 modules, 5 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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/v93/github"
	"github.com/ldez/ghactions"
	"github.com/ldez/ghactions/event"
)

func main() {
	ctx := context.Background()
	
	action, err := ghactions.NewAction(ctx)

	if err != nil {
		log.Fatal(err)
	}
	
	// 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 (
	GithubAction            = "GITHUB_ACTION"
	GithubActionPath        = "GITHUB_ACTION_PATH"
	GithubActionRepository  = "GITHUB_ACTION_REPOSITORY"
	GithubActions           = "GITHUB_ACTIONS"
	GithubActor             = "GITHUB_ACTOR"
	GithubActorID           = "GITHUB_ACTOR_ID"
	GithubAPIURL            = "GITHUB_API_URL"
	GithubArtifacts         = "GITHUB_ARTIFACTS"
	GithubArtifactsList     = "GITHUB_ARTIFACTS_LIST"
	GithubBaseRef           = "GITHUB_BASE_REF"
	GithubEnv               = "GITHUB_ENV"
	GithubEventName         = "GITHUB_EVENT_NAME"
	GithubEventPath         = "GITHUB_EVENT_PATH"
	GithubGraphqlURL        = "GITHUB_GRAPHQL_URL"
	GithubHeadRef           = "GITHUB_HEAD_REF"
	GithubJob               = "GITHUB_JOB"
	GithubOutput            = "GITHUB_OUTPUT"
	GithubPath              = "GITHUB_PATH"
	GithubRef               = "GITHUB_REF"
	GithubRefName           = "GITHUB_REF_NAME"
	GithubRefProtected      = "GITHUB_REF_PROTECTED"
	GithubRefType           = "GITHUB_REF_TYPE"
	GithubRepository        = "GITHUB_REPOSITORY"
	GithubRepositoryID      = "GITHUB_REPOSITORY_ID"
	GithubRepositoryOwner   = "GITHUB_REPOSITORY_OWNER"
	GithubRepositoryOwnerID = "GITHUB_REPOSITORY_OWNER_ID"
	GithubRetentionDays     = "GITHUB_RETENTION_DAYS"
	GithubRunAttempt        = "GITHUB_RUN_ATTEMPT"
	GithubRunID             = "GITHUB_RUN_ID"
	GithubRunNumber         = "GITHUB_RUN_NUMBER"
	GithubServerURL         = "GITHUB_SERVER_URL"
	GithubSha               = "GITHUB_SHA"
	GithubStepSummary       = "GITHUB_STEP_SUMMARY"
	GithubToken             = "GITHUB_TOKEN"
	GithubTriggeringActor   = "GITHUB_TRIGGERING_ACTOR"
	GithubWorkflow          = "GITHUB_WORKFLOW"
	GithubWorkflowRef       = "GITHUB_WORKFLOW_REF"
	GithubWorkflowSha       = "GITHUB_WORKFLOW_SHA"
	GithubWorkspace         = "GITHUB_WORKSPACE"
	RunnerArch              = "RUNNER_ARCH"
	RunnerDebug             = "RUNNER_DEBUG"
	RunnerEnvironment       = "RUNNER_ENVIRONMENT"
	RunnerName              = "RUNNER_NAME"
	RunnerOS                = "RUNNER_OS"
	RunnerTemp              = "RUNNER_TEMP"
	RunnerToolCache         = "RUNNER_TOOL_CACHE"
)

GitHub Action environment variables. https://docs.github.com/en/actions/reference/workflows-and-actions/variables

View Source
const (
	Home     = "HOME"
	Hostname = "HOSTNAME"
	Path     = "PATH"
	PWD      = "PWD"
)

Extra 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, error)

NewAction Creates a new GitHub Action executor.

func (*Action) OnBranchProtectionConfiguration added in v1.11.0

func (a *Action) OnBranchProtectionConfiguration(eventHandler func(*github.Client, *github.BranchProtectionConfigurationEvent) error) *Action

OnBranchProtectionConfiguration BranchProtectionConfiguration handler.

func (*Action) OnBranchProtectionRule added in v1.11.0

func (a *Action) OnBranchProtectionRule(eventHandler func(*github.Client, *github.BranchProtectionRuleEvent) error) *Action

OnBranchProtectionRule BranchProtectionRule handler.

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) OnCodeScanningAlert added in v1.11.0

func (a *Action) OnCodeScanningAlert(eventHandler func(*github.Client, *github.CodeScanningAlertEvent) error) *Action

OnCodeScanningAlert CodeScanning Alert handler.

func (*Action) OnCommitComment

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

OnCommitComment CommitComment handler.

func (*Action) OnContentReference added in v1.11.0

func (a *Action) OnContentReference(eventHandler func(*github.Client, *github.ContentReferenceEvent) error) *Action

OnContentReference ContentReference handler.

func (*Action) OnCreate

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

OnCreate Create handler.

func (*Action) OnCustomProperty added in v1.11.0

func (a *Action) OnCustomProperty(eventHandler func(*github.Client, *github.CustomPropertyEvent) error) *Action

OnCustomProperty CustomProperty handler.

func (*Action) OnCustomPropertyValues added in v1.11.0

func (a *Action) OnCustomPropertyValues(eventHandler func(*github.Client, *github.CustomPropertyValuesEvent) error) *Action

OnCustomPropertyValues CustomPropertyValues handler.

func (*Action) OnDelete

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

OnDelete Delete handler.

func (*Action) OnDependabotAlert added in v1.11.0

func (a *Action) OnDependabotAlert(eventHandler func(*github.Client, *github.DependabotAlertEvent) error) *Action

OnDependabotAlert DependabotAlert handler.

func (*Action) OnDeployKey added in v1.11.0

func (a *Action) OnDeployKey(eventHandler func(*github.Client, *github.DeployKeyEvent) error) *Action

OnDeployKey DeployKey handler.

func (*Action) OnDeployment

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

OnDeployment Deployment handler.

func (*Action) OnDeploymentProtectionRule added in v1.11.0

func (a *Action) OnDeploymentProtectionRule(eventHandler func(*github.Client, *github.DeploymentProtectionRuleEvent) error) *Action

OnDeploymentProtectionRule DeploymentProtectionRule handler.

func (*Action) OnDeploymentReview added in v1.11.0

func (a *Action) OnDeploymentReview(eventHandler func(*github.Client, *github.DeploymentReviewEvent) error) *Action

OnDeploymentReview DeploymentReview handler.

func (*Action) OnDeploymentStatus

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

OnDeploymentStatus DeploymentStatus handler.

func (*Action) OnDiscussion added in v1.11.0

func (a *Action) OnDiscussion(eventHandler func(*github.Client, *github.DiscussionEvent) error) *Action

OnDiscussion Discussion handler.

func (*Action) OnDiscussionComment added in v1.11.0

func (a *Action) OnDiscussionComment(eventHandler func(*github.Client, *github.DiscussionCommentEvent) error) *Action

OnDiscussionComment DiscussionComment handler.

func (*Action) OnFork

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

OnFork Fork handler.

func (*Action) OnGitHubAppAuthorization added in v1.11.0

func (a *Action) OnGitHubAppAuthorization(eventHandler func(*github.Client, *github.GitHubAppAuthorizationEvent) error) *Action

OnGitHubAppAuthorization GitHubAppAuthorization handler.

func (*Action) OnGollum

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

OnGollum Gollum handler.

func (*Action) OnInstallation added in v1.11.0

func (a *Action) OnInstallation(eventHandler func(*github.Client, *github.InstallationEvent) error) *Action

OnInstallation Installation handler.

func (*Action) OnInstallationRepositories added in v1.11.0

func (a *Action) OnInstallationRepositories(eventHandler func(*github.Client, *github.InstallationRepositoriesEvent) error) *Action

OnInstallationRepositories InstallationRepositories handler.

func (*Action) OnInstallationTarget added in v1.11.0

func (a *Action) OnInstallationTarget(eventHandler func(*github.Client, *github.InstallationTargetEvent) error) *Action

OnInstallationTarget InstallationTarget 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) OnMarketplacePurchase added in v1.11.0

func (a *Action) OnMarketplacePurchase(eventHandler func(*github.Client, *github.MarketplacePurchaseEvent) error) *Action

OnMarketplacePurchase MarketplacePurchase handler.

func (*Action) OnMember

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

OnMember Member handler.

func (*Action) OnMembership added in v1.11.0

func (a *Action) OnMembership(eventHandler func(*github.Client, *github.MembershipEvent) error) *Action

OnMembership Membership handler.

func (*Action) OnMergeGroup added in v1.11.0

func (a *Action) OnMergeGroup(eventHandler func(*github.Client, *github.MergeGroupEvent) error) *Action

OnMergeGroup MergeGroup handler.

func (*Action) OnMeta added in v1.11.0

func (a *Action) OnMeta(eventHandler func(*github.Client, *github.MetaEvent) error) *Action

OnMeta Meta handler.

func (*Action) OnMilestone

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

OnMilestone Milestone handler.

func (*Action) OnOrgBlock added in v1.11.0

func (a *Action) OnOrgBlock(eventHandler func(*github.Client, *github.OrgBlockEvent) error) *Action

OnOrgBlock OrgBlock handler.

func (*Action) OnOrganization added in v1.11.0

func (a *Action) OnOrganization(eventHandler func(*github.Client, *github.OrganizationEvent) error) *Action

OnOrganization Organization handler.

func (*Action) OnPackage added in v1.11.0

func (a *Action) OnPackage(eventHandler func(*github.Client, *github.PackageEvent) error) *Action

OnPackage Package handler.

func (*Action) OnPageBuild

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

OnPageBuild PageBuild handler.

func (*Action) OnPersonalAccessTokenRequest added in v1.11.0

func (a *Action) OnPersonalAccessTokenRequest(eventHandler func(*github.Client, *github.PersonalAccessTokenRequestEvent) error) *Action

OnPersonalAccessTokenRequest PersonalAccessTokenRequest handler.

func (*Action) OnPing added in v1.11.0

func (a *Action) OnPing(eventHandler func(*github.Client, *github.PingEvent) error) *Action

OnPing Ping handler.

func (*Action) OnProject

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

OnProject Project handler.

func (*Action) OnProjectItem added in v1.11.0

func (a *Action) OnProjectItem(eventHandler func(*github.Client, *github.ProjectV2ItemEvent) error) *Action

OnProjectItem ProjectItem 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) OnRepository added in v1.11.0

func (a *Action) OnRepository(eventHandler func(*github.Client, *github.RepositoryEvent) error) *Action

OnRepository Repository handler.

func (*Action) OnRepositoryDispatch added in v1.11.0

func (a *Action) OnRepositoryDispatch(eventHandler func(*github.Client, *github.RepositoryDispatchEvent) error) *Action

OnRepositoryDispatch RepositoryDispatch handler.

func (*Action) OnRepositoryImport added in v1.11.0

func (a *Action) OnRepositoryImport(eventHandler func(*github.Client, *github.RepositoryImportEvent) error) *Action

OnRepositoryImport RepositoryImport handler.

func (*Action) OnRepositoryRuleset added in v1.11.0

func (a *Action) OnRepositoryRuleset(eventHandler func(*github.Client, *github.RepositoryRulesetEvent) error) *Action

OnRepositoryRuleset RepositoryRuleset handler.

func (*Action) OnRepositoryVulnerabilityAlert

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

OnRepositoryVulnerabilityAlert RepositoryVulnerabilityAlert handler.

func (*Action) OnSecretScanningAlert added in v1.11.0

func (a *Action) OnSecretScanningAlert(eventHandler func(*github.Client, *github.SecretScanningAlertEvent) error) *Action

OnSecretScanningAlert SecretScanningAlert handler.

func (*Action) OnSecretScanningAlertLocation added in v1.11.0

func (a *Action) OnSecretScanningAlertLocation(eventHandler func(*github.Client, *github.SecretScanningAlertLocationEvent) error) *Action

OnSecretScanningAlertLocation SecretScanningAlertLocation handler.

func (*Action) OnSecurityAdvisory added in v1.11.0

func (a *Action) OnSecurityAdvisory(eventHandler func(*github.Client, *github.SecurityAdvisoryEvent) error) *Action

OnSecurityAdvisory Security Advisory handler.

func (*Action) OnSecurityAndAnalysis added in v1.11.0

func (a *Action) OnSecurityAndAnalysis(eventHandler func(*github.Client, *github.SecurityAndAnalysisEvent) error) *Action

OnSecurityAndAnalysis SecurityAndAnalysis handler.

func (*Action) OnSponsorship added in v1.11.0

func (a *Action) OnSponsorship(eventHandler func(*github.Client, *github.SponsorshipEvent) error) *Action

OnSponsorship Sponsorship handler.

func (*Action) OnStar added in v1.11.0

func (a *Action) OnStar(eventHandler func(*github.Client, *github.StarEvent) error) *Action

OnStar Star handler.

func (*Action) OnStatus

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

OnStatus Status handler.

func (*Action) OnTeam added in v1.11.0

func (a *Action) OnTeam(eventHandler func(*github.Client, *github.TeamEvent) error) *Action

OnTeam Team handler.

func (*Action) OnTeamAdd added in v1.11.0

func (a *Action) OnTeamAdd(eventHandler func(*github.Client, *github.TeamAddEvent) error) *Action

OnTeamAdd Team Add handler.

func (*Action) OnUser added in v1.11.0

func (a *Action) OnUser(eventHandler func(*github.Client, *github.UserEvent) error) *Action

OnUser User handler.

func (*Action) OnWatch

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

OnWatch Watch handler.

func (*Action) OnWorkflowDispatch added in v1.11.0

func (a *Action) OnWorkflowDispatch(eventHandler func(*github.Client, *github.WorkflowDispatchEvent) error) *Action

OnWorkflowDispatch Workflow Dispatch handler.

func (*Action) OnWorkflowJob added in v1.11.0

func (a *Action) OnWorkflowJob(eventHandler func(*github.Client, *github.WorkflowJobEvent) error) *Action

OnWorkflowJob Workflow Job handler.

func (*Action) OnWorkflowRun added in v1.11.0

func (a *Action) OnWorkflowRun(eventHandler func(*github.Client, *github.WorkflowRunEvent) error) *Action

OnWorkflowRun Workflow Run 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