githubx

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EnvGitHubRepository is the actions-provided repo slug "owner/name".
	EnvGitHubRepository = "GITHUB_REPOSITORY"
	// EnvGitHubEventPath carries the workflow event payload JSON path.
	EnvGitHubEventPath = "GITHUB_EVENT_PATH"
	// EnvGitHubToken carries the bearer token used by REST calls.
	EnvGitHubToken = "GITHUB_TOKEN"
	// EnvGitHubOutput names the file path for step outputs.
	EnvGitHubOutput = "GITHUB_OUTPUT"
	// EnvMode selects unreleased vs release engine behaviour.
	EnvMode = "MODE"
	// EnvTargetVersion is the semver X.Y.Z for release mode (no leading v).
	EnvTargetVersion = "TARGET_VERSION"
	// EnvTargetBranch optionally overrides the branch name written to outputs.
	EnvTargetBranch = "TARGET_BRANCH"
	// EnvChangelogPath overrides the CHANGELOG.md path.
	EnvChangelogPath = "CHANGELOG_PATH"
	// EnvPreviousTag is the tag spanning the changelog compare range baseline.
	EnvPreviousTag = "PREVIOUS_TAG"
	// EnvCompareRange is git rev-list range (e.g. v1.0.0..HEAD).
	EnvCompareRange = "COMPARE_RANGE"
	// EnvInput* mirror actions/core getInput env fallbacks used by github-script steps.
	EnvInputPreviousTag   = "INPUT_PREVIOUS_TAG"
	EnvInputCompareRange  = "INPUT_COMPARE_RANGE"
	EnvInputMode          = "INPUT_MODE"
	EnvInputTargetVersion = "INPUT_TARGET_VERSION"
)

Variables

This section is empty.

Functions

func AppendGitHubOutput

func AppendGitHubOutput(path, name, value string) error

AppendGitHubOutput appends name=value pairs to path (the file named by GITHUB_OUTPUT). Single-line values use "name=value\n". Values containing newlines use GitHub Actions heredoc framing with a random delimiter token.

func CreateIssueComment

func CreateIssueComment(ctx context.Context, client *github.Client, owner, repo string, issueNumber int, body string) error

CreateIssueComment adds a comment to issueNumber.

func DecodeEvent

func DecodeEvent[T any](data []byte) (T, error)

DecodeEvent unmarshals raw JSON workflow event bytes into T.

func GitHubOutputPath

func GitHubOutputPath() string

GitHubOutputPath returns trimmed GITHUB_OUTPUT (may be empty).

func GitHubToken

func GitHubToken() string

GitHubToken returns trimmed GITHUB_TOKEN (may be empty).

func ListCommitSHAs

func ListCommitSHAs(exec semver.Execer, compareRange string) ([]string, error)

ListCommitSHAs executes `git log --format=%H <range>` like changelog-engine-factory.js gatherMergedPRRecordsForRange.

func ListPullRequestFilenames

func ListPullRequestFilenames(
	ctx context.Context,
	client *github.Client,
	owner, repo string,
	pullNumber int,
) ([]string, error)

ListPullRequestFilenames returns each changed file path for pullNumber (paginated). Mirrors pulls.listFiles usage in the changelog evidence gather path.

func LoadEvent

func LoadEvent[T any](path string) (T, error)

LoadEvent decodes the JSON workflow event at path into a typed value T.

func NewGitHubClient

func NewGitHubClient(_ context.Context, token string) (*github.Client, error)

NewGitHubClient returns a GitHub API client authenticated with token, mirroring scripts/auto-approve/main.go.

func OptionalPullRequestNumberFromEventPath

func OptionalPullRequestNumberFromEventPath(path string) (int, error)

OptionalPullRequestNumberFromEventPath returns payload.pull_request.number when the field is present. An empty path returns (0, nil). This mirrors optional chaining on context.payload.pull_request?.number used by changelog workflow scripts.

func OwnerRepoFromEnv

func OwnerRepoFromEnv() (owner, repo string, err error)

OwnerRepoFromEnv reads GITHUB_REPOSITORY.

func ParseGitHubOwnerRepo

func ParseGitHubOwnerRepo(repository string) (owner, repo string, err error)

ParseGitHubOwnerRepo parses github.repository-style "owner/name".

func PullRequestsAssociatedWithCommit

func PullRequestsAssociatedWithCommit(
	ctx context.Context,
	client *github.Client,
	owner, repo, sha string,
) ([]*github.PullRequest, error)

PullRequestsAssociatedWithCommit lists merged/closed associations for sha (paginated).

func ReadEventPayload

func ReadEventPayload(path string) ([]byte, error)

ReadEventPayload reads the raw JSON payload from path (typically $GITHUB_EVENT_PATH).

func UpdateIssueComment

func UpdateIssueComment(ctx context.Context, client *github.Client, owner, repo string, commentID int64, body string) error

UpdateIssueComment edits an existing issue comment's body.

Types

type ChangelogPullSummary

type ChangelogPullSummary struct {
	Number int
	URL    string
}

ChangelogPullSummary captures number and HTML URL returned from pull request APIs.

type ChangelogWorkflowPullRequests

type ChangelogWorkflowPullRequests struct {
	Client *github.Client
}

ChangelogWorkflowPullRequests implements GitHub pulls/issues calls used by changelog-generation workflow helpers (changelog-pr-management.js parity).

func (*ChangelogWorkflowPullRequests) AddIssueLabels

func (w *ChangelogWorkflowPullRequests) AddIssueLabels(ctx context.Context, owner, repo string, issueNumber int, labels []string) error

AddIssueLabels attaches labels to a pull (issues.addLabels parity).

func (*ChangelogWorkflowPullRequests) CreatePullRequest

func (w *ChangelogWorkflowPullRequests) CreatePullRequest(ctx context.Context, owner, repo string, title, body, head, base string) (*ChangelogPullSummary, error)

CreatePullRequest opens a pull request (mirrors pulls.create inputs used by changelog workflow).

func (*ChangelogWorkflowPullRequests) ListOpenPullRequestsByHead

func (w *ChangelogWorkflowPullRequests) ListOpenPullRequestsByHead(ctx context.Context, owner, repo, headRef, baseBranch string) ([]ChangelogPullSummary, error)

ListOpenPullRequestsByHead lists open pulls where Head is owner:branchSlug and Base is baseBranch.

func (*ChangelogWorkflowPullRequests) UpdatePullRequestBody

func (w *ChangelogWorkflowPullRequests) UpdatePullRequestBody(ctx context.Context, owner, repo string, number int, body string) error

UpdatePullRequestBody sets the pull body (mirrors pulls.update body-only updates).

type IssueComment

type IssueComment struct {
	ID        int64
	Body      string
	UserLogin string
}

IssueComment summarizes a REST issue comment (PR comments use the issue comments API).

func ListIssueComments

func ListIssueComments(ctx context.Context, client *github.Client, owner, repo string, issueNumber int) ([]IssueComment, error)

ListIssueComments lists all comments for issueNumber (paginated).

type ShellGit

type ShellGit struct{}

ShellGit adapts semver.Execer to exec.Command(..). Output() calls.

func (ShellGit) Run

func (ShellGit) Run(name string, args ...string) ([]byte, error)

Run invokes name with argv and captures stdout (+ stderr folded into Output error payload).

Jump to

Keyboard shortcuts

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