github

package
v1.222.0-rc.0 Latest Latest
Warning

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

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

Documentation

Overview

Package github implements the CI cache Backend against the GitHub Actions cache (Cache Service v2). It speaks the Twirp JSON API at ACTIONS_RESULTS_URL (authenticated with ACTIONS_RUNTIME_TOKEN) for save/restore, uploads/downloads content through the returned Azure Blob SAS URLs, and uses the public REST caches API for list/delete.

Save/restore of content require the Actions runtime token and results URL, which are only present inside a GitHub Actions runner; outside a runner those operations return errUtils.ErrCacheUnavailable. List/delete are pure cache administration over the public REST API and work anywhere a GitHub token and the repository (owner/repo) can be resolved, so NewBackend constructs an admin-capable backend even outside a runner.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBackend

func NewBackend(opts cache.Options) (cache.Backend, error)

NewBackend constructs the GitHub Actions cache backend.

List/delete (cache administration) work anywhere: they use the public REST caches API authenticated with an ordinary GitHub token and the repository's owner/repo (resolved from GITHUB_REPOSITORY or the local git remote). Save and restore of content additionally require the Actions runtime token and results URL (ACTIONS_RUNTIME_TOKEN + ACTIONS_RESULTS_URL), which are only present inside a GitHub Actions runner; when they are absent the returned backend has no runtime client and Save/Restore report errUtils.ErrCacheUnavailable.

Types

type Backend

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

Backend implements cache.Backend using the GitHub Actions cache.

func (*Backend) Delete

func (b *Backend) Delete(ctx context.Context, key string) error

Delete removes a cache entry by key via the REST caches API. Missing keys are a no-op.

func (*Backend) List

func (b *Backend) List(ctx context.Context, opts cache.ListOptions) ([]cache.Entry, error)

List returns cache entries via the REST caches API, filtered by key prefix.

func (*Backend) Name

func (b *Backend) Name() string

Name returns the backend type name.

func (*Backend) Restore

func (b *Backend) Restore(ctx context.Context, key string, restoreKeys []string) (string, io.ReadCloser, error)

Restore downloads the entry for key, falling back to restoreKeys. Returns ErrCacheNotFound when nothing matches.

func (*Backend) Save

func (b *Backend) Save(ctx context.Context, key string, data io.Reader, size int64) error

Save uploads data under key. Returns ErrCacheAlreadyExists when the key exists.

Jump to

Keyboard shortcuts

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