githubactions

package
v0.0.0-...-80ccc60 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Ecosystem is the ecosystem identifier for GitHub Actions.
	Ecosystem = "github-actions"
)

Variables

This section is empty.

Functions

func RewriteWorkflow

func RewriteWorkflow(root *os.Root, relPath string, updates []pin.Update) error

RewriteWorkflow applies pin updates to a single workflow file within the given root directory. It uses regex-based replacement to preserve YAML formatting, indentation, quotes, and unrelated comments.

The output format is Dependabot-compatible:

uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

Types

type Resolver

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

Resolver resolves action references to commit SHAs and semver tags using the git protocol (ls-remote). This works with any git hosting provider and does not require a REST API token — credentials are sourced from the standard auth store for private repos only.

A single ls-remote call returns all refs, avoiding the N+1 API call pattern of REST-based resolution.

func NewResolver

func NewResolver() *Resolver

NewResolver creates a Resolver that uses the git protocol for ref resolution.

func (*Resolver) ResolveSHA

func (r *Resolver) ResolveSHA(ctx context.Context, owner, repo, ref string) (string, error)

ResolveSHA resolves a Git ref (tag, branch, or SHA) to a full 40-character commit SHA by querying the remote via the git protocol.

func (*Resolver) ResolveTag

func (r *Resolver) ResolveTag(ctx context.Context, owner, repo, sha string) (string, error)

ResolveTag finds the most specific semver tag pointing at the given commit SHA. It lists all refs via ls-remote (cached per repository) and returns the best match (e.g., v4.2.2 over v4.2 over v4).

type Strategy

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

Strategy implements the pin.Strategy interface for GitHub Actions workflow dependencies. It discovers uses: references in:

  • .github/workflows/*.yml — standard workflow files
  • action.yml / action.yaml at repo root — if the repo IS a GitHub Action
  • .github/actions/*/action.yml — local composite actions
  • any action.yml / action.yaml in the repo tree — arbitrary composite actions

It resolves tags to commit SHAs via the git protocol, verifies commits for fork/imposter provenance via the GitHub REST API, and rewrites files with Dependabot-compatible SHA pins.

func NewStrategy

func NewStrategy(client *github.Client) *Strategy

NewStrategy creates a Strategy for GitHub Actions pinning. The resolver uses the git protocol (no API client needed). The verifier uses the GitHub REST API client for commit provenance checks — pass nil to skip verification capabilities.

func (*Strategy) Discover

func (s *Strategy) Discover(ctx context.Context, fsys scalibrfs.FS) ([]pin.Ref, error)

Discover implements pin.Strategy. It finds all files containing GitHub Actions uses: references — both workflow files and composite action manifests.

func (*Strategy) Ecosystem

func (s *Strategy) Ecosystem() string

Ecosystem implements pin.Strategy.

func (*Strategy) IsPinned

func (s *Strategy) IsPinned(ref pin.Ref) bool

IsPinned implements pin.Strategy. A GitHub Actions ref is pinned when its version is a 40-character hex commit SHA.

func (*Strategy) Resolve

func (s *Strategy) Resolve(ctx context.Context, ref pin.Ref) (pinnedValue, versionTag string, err error)

Resolve implements pin.Strategy. It resolves a mutable tag/branch to a commit SHA and finds the most specific semver tag for the Dependabot comment.

func (*Strategy) ResolveUpdate

func (s *Strategy) ResolveUpdate(ctx context.Context, ref pin.Ref) (string, string, string, error)

ResolveUpdate implements pin.Strategy. It re-resolves an already-pinned ref to the latest SHA in its major version channel (e.g., v4 → latest v4.x.x).

func (*Strategy) Rewrite

func (s *Strategy) Rewrite(root *os.Root, relPath string, updates []pin.Update) error

Rewrite implements pin.Strategy. It rewrites workflow/action YAML files with SHA pins.

func (*Strategy) ShouldSkip

func (s *Strategy) ShouldSkip(ref pin.Ref) (bool, string)

ShouldSkip implements pin.Strategy. GitHub Actions refs containing expression syntax (${{ ... }}) cannot be statically pinned and should be skipped.

func (*Strategy) Verify

func (s *Strategy) Verify(ctx context.Context, ref pin.Ref) (*pin.Verification, error)

Verify implements pin.Strategy. It checks commit provenance for fork/imposter detection and signature verification. Returns nil if no verifier is configured (e.g., no GitHub API client available).

type Verifier

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

Verifier checks commit provenance using the GitHub API to detect fork/imposter commits and unsigned commits.

func NewVerifier

func NewVerifier(client *github.Client) *Verifier

NewVerifier creates a Verifier using the provided GitHub API client.

func (*Verifier) Verify

func (v *Verifier) Verify(ctx context.Context, owner, repo, sha string) (*pin.Verification, error)

Verify checks whether a commit SHA is trustworthy in the given repository. It checks:

  1. Whether the commit is signed (GPG/SSH signature verified by GitHub).
  2. Whether the commit is reachable from the repository's default branch.
  3. Whether the commit might be a fork/imposter commit (fetchable from the shared object store but not belonging to any branch).

Jump to

Keyboard shortcuts

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