gha

package module
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License: BSD-2-Clause Imports: 5 Imported by: 3

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Branding added in v0.4.0

type Branding struct {
	Color string `yaml:"color"`
	Icon  string `yaml:"icon"`
}

Branding is a model of an Action Manifest's `branding:` object.

type Concurrency added in v0.5.0

type Concurrency struct {
	CancelInProgress string `yaml:"cancel-in-progress,omitempty"`
	Group            string `yaml:"group,omitempty"`
}

Concurrency is a model of a GitHub Actions `concurrency:` object.

func (*Concurrency) UnmarshalYAML added in v0.5.2

func (c *Concurrency) UnmarshalYAML(n *yaml.Node) error

type Defaults added in v0.5.0

type Defaults struct {
	Run DefaultsRun `yaml:"run,omitempty"`
}

Defaults is a model of a GitHub Actions `defaults:` object.

type DefaultsRun added in v0.5.0

type DefaultsRun struct {
	Shell            string `yaml:"shell,omitempty"`
	WorkingDirectory string `yaml:"working-directory,omitempty"`
}

DefaultsRun is a model of a GitHub Actions `defaults.run:` object.

type Environment added in v0.5.0

type Environment struct {
	Name string `yaml:"name,omitempty"`
	Url  string `yaml:"url,omitempty"`
}

Environment is a model of a GitHub Actions `environment:` object.

func (*Environment) UnmarshalYAML added in v0.5.0

func (e *Environment) UnmarshalYAML(n *yaml.Node) error

type Input added in v0.4.0

type Input struct {
	Description        string `yaml:"description"`
	Default            string `yaml:"default,omitempty"`
	Required           bool   `yaml:"required,omitempty"`
	DeprecationMessage string `yaml:"deprecationMessage,omitempty"`
}

Input is a model of an Action Manifest's `inputs:`.

type Job

type Job struct {
	Name            string             `yaml:"name,omitempty"`
	Environment     Environment        `yaml:"environment,omitempty"`
	ContinueOnError bool               `yaml:"continue-on-error,omitempty"`
	TimeoutMinutes  int                `yaml:"timeout-minutes,omitempty"`
	If              string             `yaml:"if,omitempty"`
	Needs           Needs              `yaml:"needs,omitempty"`
	Concurrency     Concurrency        `yaml:"concurrency,omitempty"`
	Defaults        Defaults           `yaml:"defaults,omitempty"`
	Strategy        Strategy           `yaml:"strategy,omitempty"`
	Services        map[string]Service `yaml:"services,omitempty"`
	Outputs         map[string]string  `yaml:"outputs,omitempty"`
	Permissions     Permissions        `yaml:"permissions,omitempty"`
	Env             map[string]string  `yaml:"env,omitempty"`

	Steps []Step `yaml:"steps,omitempty"`

	Uses string            `yaml:"uses,omitempty"`
	With map[string]string `yaml:"with,omitempty"`
}

Job is a model of a GitHub Actions workflow job.

type Manifest

type Manifest struct {
	Name        string   `yaml:"name"`
	Author      string   `yaml:"author,omitempty"`
	Description string   `yaml:"description"`
	Branding    Branding `yaml:"branding,omitempty"`

	Inputs  map[string]Input  `yaml:"inputs,omitempty"`
	Outputs map[string]Output `yaml:"outputs,omitempty"`

	Runs Runs `yaml:"runs"`
}

Manifest is a model of a GitHub Actions Action manifest.

func ParseManifest

func ParseManifest(data []byte) (Manifest, error)

ParseManifest parses a GitHub Actions Action manifest into a Manifest.

Example
yaml := `
name: Hello World
description: Greet someone and record the time
inputs:
  who-to-greet:  # id of input
    description: Who to greet
    required: true
    default: World
outputs:
  time: # id of output
    description: The time we greeted you
runs:
  using: node20
  main: index.js`

manifest, _ := ParseManifest([]byte(yaml))
fmt.Println(manifest.Name)
Output:
Hello World

type Matrix added in v0.5.1

type Matrix []map[string]any

Matrix is a model of a GitHub Actions `strategy.matrix:` object.

func (*Matrix) UnmarshalYAML added in v0.5.1

func (m *Matrix) UnmarshalYAML(n *yaml.Node) error

type Needs added in v0.5.2

type Needs []string

func (*Needs) UnmarshalYAML added in v0.5.2

func (l *Needs) UnmarshalYAML(n *yaml.Node) error

type Output added in v0.4.0

type Output struct {
	Description string `yaml:"description"`
	Value       string `yaml:"value"`
}

Output is a model of an Action Manifest's `outputs:`.

type Permissions added in v0.5.0

type Permissions struct {
	Actions        string `yaml:"actions,omitempty"`
	Attestations   string `yaml:"attestations,omitempty"`
	Checks         string `yaml:"checks,omitempty"`
	Contents       string `yaml:"contents,omitempty"`
	Deployments    string `yaml:"deployments,omitempty"`
	Discussions    string `yaml:"discussions,omitempty"`
	IdToken        string `yaml:"id-token,omitempty"`
	Issues         string `yaml:"issues,omitempty"`
	Models         string `yaml:"models,omitempty"`
	Packages       string `yaml:"packages,omitempty"`
	Pages          string `yaml:"pages,omitempty"`
	PullRequests   string `yaml:"pull-requests,omitempty"`
	SecurityEvents string `yaml:"security-events,omitempty"`
	Statuses       string `yaml:"statuses,omitempty"`
}

Permissions is a model of a GitHub Actions `permissions:` object.

func (*Permissions) UnmarshalYAML added in v0.5.0

func (p *Permissions) UnmarshalYAML(n *yaml.Node) error

type Ports added in v0.6.0

type Ports []string

type Runs added in v0.3.0

type Runs struct {
	Using string `yaml:"using"`

	Steps []Step `yaml:"steps,omitempty"`

	Image          string            `yaml:"image,omitempty"`
	PreEntrypoint  string            `yaml:"pre-entrypoint,omitempty"`
	Entrypoint     string            `yaml:"entrypoint,omitempty"`
	PostEntrypoint string            `yaml:"post-entrypoint,omitempty"`
	Args           []string          `yaml:"args,omitempty"`
	Env            map[string]string `yaml:"env,omitempty"`

	Pre    string `yaml:"pre,omitempty"`
	PreIf  string `yaml:"pre-if,omitempty"`
	Main   string `yaml:"main,omitempty"`
	Post   string `yaml:"post,omitempty"`
	PostIf string `yaml:"post-if,omitempty"`
}

Runs is a model of an Action Manifest's `runs:` object.

type Service added in v0.5.0

type Service struct {
	Image       string             `yaml:"image"`
	Credentials ServiceCredentials `yaml:"credentials,omitempty"`
	Env         map[string]string  `yaml:"env,omitempty"`
	Ports       Ports              `yaml:"ports,omitempty"`
	Volumes     []string           `yaml:"volumes,omitempty"`
	Options     string             `yaml:"options,omitempty"`
}

Service is a model of a GitHub Actions `services:` object.

type ServiceCredentials added in v0.5.0

type ServiceCredentials struct {
	Username string `yaml:"username"`
	Password string `yaml:"password"`
}

ServiceCredentials is a model of a GitHub Actions `services.credentials:` object.

type Step

type Step struct {
	Name             string            `yaml:"name,omitempty"`
	Uses             Uses              `yaml:"uses,omitempty"`
	Id               string            `yaml:"id,omitempty"`
	If               string            `yaml:"if,omitempty"`
	ContinueOnError  bool              `yaml:"continue-on-error,omitempty"`
	TimeoutMinutes   uint              `yaml:"timeout-minutes,omitempty"`
	WorkingDirectory string            `yaml:"working-directory,omitempty"`
	Shell            string            `yaml:"shell,omitempty"`
	Run              string            `yaml:"run,omitempty"`
	With             map[string]string `yaml:"with,omitempty"`
	Env              map[string]string `yaml:"env,omitempty"`
}

Step is a model of a workflow/manifest job step.

type Strategy added in v0.5.1

type Strategy struct {
	Matrix      Matrix `yaml:"matrix,omitempty"`
	FailFast    bool   `yaml:"fail-fast,omitempty"`
	MaxParallel int    `yaml:"max-parallel,omitempty"`
}

Strategy is a model of a GitHub Actions `strategy:` object.

type Uses

type Uses struct {
	// Name is the name of the Action that is used. Typically <owner>/<repository>.
	Name string

	// Ref is the git reference used for the Action. Typically a tag ref, branch ref, or commit SHA.
	Ref string

	// Annotation is the comment after the `uses:` value, if any.
	Annotation string
}

Uses is a model of a step `uses:` value.

func (*Uses) IsLocal added in v0.9.0

func (u *Uses) IsLocal() bool

IsLocal reperts whether the uses value is for a local or remote Action.

func (*Uses) UnmarshalYAML added in v0.2.0

func (u *Uses) UnmarshalYAML(n *yaml.Node) error

type Workflow

type Workflow struct {
	Name        string            `yaml:"name,omitempty"`
	RunName     string            `yaml:"run-name,omitempty"`
	Permissions Permissions       `yaml:"permissions,omitempty"`
	Concurrency Concurrency       `yaml:"concurrency,omitempty"`
	Defaults    Defaults          `yaml:"defaults,omitempty"`
	Env         map[string]string `yaml:"env,omitempty"`
	Jobs        map[string]Job    `yaml:"jobs"`
}

Workflow is a model of a GitHub Actions workflow.

func ParseWorkflow

func ParseWorkflow(data []byte) (Workflow, error)

ParseWorkflow parses a GitHub Actions workflow into a Workflow.

Example
yaml := `
name: learn-github-actions
run-name: ${{ github.actor }} is learning GitHub Actions
on: [push]
jobs:
  check-bats-version:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: actions/setup-node@v4
      with:
        node-version: '20'
    - run: npm install -g bats
    - run: bats -v`

workflow, _ := ParseWorkflow([]byte(yaml))
fmt.Println(workflow.Name)
Output:
learn-github-actions

Jump to

Keyboard shortcuts

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