github

package
v5.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: MIT Imports: 7 Imported by: 0

README

pkg/cicd/github

GitHub Deployments API implementation of the Theatre CI/CD deployer interface.

Overview

This package implements cicd.Deployer using the GitHub Deployments API. It creates GitHub deployment events that can be consumed by any CI/CD system watching for them (e.g., GitHub Actions, external deployment tools).

How It Works

  1. Trigger: Creates a GitHub deployment event on a specified repository/revision
  2. Status: Polls GitHub deployment statuses to track progress
  3. Metadata: Includes rollback context (target, creator, reason) in the deployment payload

Configuration

The deployer requires:

  • deployment_revision_name (required): Name of the revision in the release config where the deployment should be created
  • environment (optional): GitHub environment name for the deployment

Additional options in DeploymentRequest.Options are merged into the deployment payload.

Revision Requirements

The target release must contain a revision with:

  • Type: "github"
  • Source: "owner/repo" format
  • ID: Git ref (commit SHA, branch, or tag)

Deployment Payload

The GitHub deployment payload includes:

{
  "version": 3,
  "target": "production",
  "creator": "user@example.com",
  "is_rollback": true,
  "rollback_from": "release-v2.0",
  "rollback_to": "release-v1.9",
  "reason": "Critical bug in v2.0",
  // ... additional user options
}

Status Mapping

GitHub deployment states are mapped to Theatre deployment statuses:

  • success → Succeeded
  • failure, error → Failed
  • pending, queued → Pending
  • in_progress → InProgress

Documentation

Index

Constants

View Source
const (
	DeploymentRevisionNameKey = "deployment_revision_name"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Deployer

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

Deployer implements cicd.Deployer using the GitHub Deployments API. This creates GitHub deployment events that can be consumed by any CICD system that watches for them.

The deployer extracts owner/repo from the target release's revision with Type="github" and Source in "owner/repo" format. Environment is optionally taken from Options["environment"].

func NewDeployer

func NewDeployer(client *github.Client, logger logr.Logger) *Deployer

NewDeployer creates a new GitHub Deployments deployer.

func (*Deployer) GetDeploymentStatus

func (d *Deployer) GetDeploymentStatus(ctx context.Context, deploymentID string) (*cicd.DeploymentResult, error)

GetDeploymentStatus retrieves the current status of a GitHub deployment. The deploymentID should be the URL returned from TriggerDeployment (e.g., "https://github.com/owner/repo/deployments/123").

func (*Deployer) Name

func (d *Deployer) Name() string

func (*Deployer) TriggerDeployment

func (d *Deployer) TriggerDeployment(ctx context.Context, req cicd.DeploymentRequest) (*cicd.DeploymentResult, error)

TriggerDeployment creates a GitHub deployment event. GitHub deployments require the "deployment_revision_name" field to be set in the req.Options map. E.g. "deployment_revision_name": "application". This is the name of the revision on which the GitHub deployment will be created.

Jump to

Keyboard shortcuts

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