github

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseActionYAML

func ParseActionYAML(data []byte) (map[string]interface{}, error)

ParseActionYAML parses YAML data into a map that can be JSON-encoded. This converts the action.yml structure into a JSON-compatible format.

Types

type ActionsService

type ActionsService struct {
	// contains filtered or unexported fields
}

ActionsService provides functionality to fetch and parse GitHub Actions.

func NewActionsService

func NewActionsService() *ActionsService

NewActionsService creates a new ActionsService.

func (*ActionsService) FetchActionYAML

func (s *ActionsService) FetchActionYAML(owner, repo, version string) ([]byte, error)

FetchActionYAML fetches the action.yml or action.yaml file from GitHub's raw content CDN. It tries both common action file names in order of preference. It constructs the URL using tags format: https://raw.githubusercontent.com/{owner}/{repo}/refs/tags/{version}/action.yml

func (*ActionsService) FetchRawFile

func (s *ActionsService) FetchRawFile(owner, repo, urlPath, filename string) ([]byte, error)

FetchRawFile fetches a file from GitHub's raw content CDN. The urlPath should specify the path type and version:

  • For tags: "refs/tags/{version}"
  • For branches: "refs/heads/{branch}"
  • For commits: "{sha}"

func (*ActionsService) FetchReadme

func (s *ActionsService) FetchReadme(owner, repo, ref string) (string, error)

FetchReadme fetches the README.md file from GitHub's raw content CDN. It tries multiple common README filenames in order of preference. The ref can be a branch name, tag, or commit SHA.

func (*ActionsService) GetActionParameters

func (s *ActionsService) GetActionParameters(actionRef string) (map[string]interface{}, error)

GetActionParameters fetches and parses a GitHub Action's action.yml file. It takes an action reference (e.g., "actions/checkout@v5") and returns the parsed action.yml content as a JSON-compatible map.

func (*ActionsService) GetActionParametersJSON

func (s *ActionsService) GetActionParametersJSON(actionRef string) (string, error)

GetActionParametersJSON is a convenience method that returns the action parameters as a JSON string instead of a map.

func (*ActionsService) GetReadme

func (s *ActionsService) GetReadme(repoRef string) (string, error)

GetReadme fetches a README.md file from a GitHub repository. It takes a repository reference (e.g., "owner/repo@main" or "owner/repo") and returns the README content as a string. If no ref is provided, it defaults to "main".

type Ref

type Ref struct {
	Owner   string
	Repo    string
	Version string // Can be a tag, branch, commit SHA, or version
}

Ref represents a parsed GitHub reference (repository or action).

func ParseActionRef

func ParseActionRef(ref string) (*Ref, error)

ParseActionRef parses an action reference string like "owner/repo@version". The version part is required for actions. Examples:

  • "actions/checkout@v5" -> {Owner: "actions", Repo: "checkout", Version: "v5"}
  • "actions/setup-node@v4" -> {Owner: "actions", Repo: "setup-node", Version: "v4"}

func ParseRef

func ParseRef(ref string, requireVersion bool, defaultVersion string) (*Ref, error)

ParseRef parses a GitHub reference string like "owner/repo@version". If requireVersion is true, the @version part is mandatory. If requireVersion is false and no @version is provided, defaultVersion is used.

Examples:

  • "actions/checkout@v5" -> {Owner: "actions", Repo: "checkout", Version: "v5"}
  • "owner/repo@main" -> {Owner: "owner", Repo: "repo", Version: "main"}
  • "owner/repo" with defaultVersion="main" -> {Owner: "owner", Repo: "repo", Version: "main"}

func ParseRepoRef

func ParseRepoRef(ref string) (*Ref, error)

ParseRepoRef parses a repository reference string like "owner/repo@ref". The ref can be a tag, branch name, or commit SHA. If no ref is provided (e.g., "owner/repo"), it defaults to "main". Examples:

  • "actions/checkout@v5" -> {Owner: "actions", Repo: "checkout", Version: "v5"}
  • "owner/repo@main" -> {Owner: "owner", Repo: "repo", Version: "main"}
  • "owner/repo" -> {Owner: "owner", Repo: "repo", Version: "main"}

Jump to

Keyboard shortcuts

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