githubactions

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: Apache-2.0 Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

starlark-githubactions

Go Reference

starlark-go wrappers for go-githubactions - easily author GitHub Actions in Starlark.

Documentation

Overview

Package githubactions provides starlark-go wrappers for go-githubactions.

Example
package main

import (
	"fmt"
	"log"
	"os"

	githubactions "github.com/AlekSi/starlark-githubactions"
	gogithubactions "github.com/sethvargo/go-githubactions"
	"go.starlark.net/starlark"
	"go.starlark.net/syntax"
)

func main() {
	// Create a Starlark module for this example.
	getenv := func(key string) string {
		switch key {
		case "GITHUB_EVENT_PATH":
			return "event.json"
		default:
			return ""
		}
	}
	module := githubactions.NewModule(
		"githubactions",
		githubactions.New(gogithubactions.New(
			gogithubactions.WithWriter(os.Stdout),
			gogithubactions.WithGetenv(getenv),
		)),
	)

	// Add module to the predeclared global environment.
	// Most users should use githubactions.Module instead.
	predeclared := starlark.StringDict{
		"githubactions": module,
	}

	script := `
def check_pr():
	ctx = githubactions.context()
	pr = ctx.event.get("pull_request", {})
	if not pr:
		fail("Not a 'pull_request' event")

	merge_method = pr.get("auto_merge", {}).get("merge_method", "")
	if not merge_method:
		fail("Auto-merge should be enabled")

	print("Merge method:", merge_method)

check_pr()
`

	opts := &syntax.FileOptions{}
	thread := &starlark.Thread{
		Print: func(th *starlark.Thread, msg string) {
			fmt.Println(msg)
		},
	}

	if _, err := starlark.ExecFileOptions(opts, thread, "check_pr.star", script, predeclared); err != nil {
		log.Fatal(err)
	}
}
Output:
Merge method: squash

Index

Examples

Constants

This section is empty.

Variables

Module is the GitHub Actions Starlark module.

Functions

func NewModule

func NewModule(name string, a *Action) *starlarkstruct.Module

NewModule constructs a Starlark module for the given Action.

Types

type Action

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

Action wraps githubactions.Action for Starlark.

func New

func New(a *githubactions.Action) *Action

New creates a new Action.

func (*Action) AddMask

func (a *Action) AddMask(th *starlark.Thread, fn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

AddMask adds a new field mask for the given value. After called, future attempts to log the value will be replaced with "***" in log output. See https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands#masking-a-value-in-a-log.

func (*Action) AddMatcher

func (a *Action) AddMatcher(th *starlark.Thread, fn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

AddMatcher adds a new matcher with the given file path.

func (*Action) AddPath

func (a *Action) AddPath(th *starlark.Thread, fn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

AddPath adds a new system path to the PATH environment variable. See https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands#adding-a-system-path.

func (*Action) AddStepSummary

func (a *Action) AddStepSummary(th *starlark.Thread, fn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

AddStepSummary writes the given markdown to the job summary. If a job summary already exists, this value is appended. See https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands#adding-a-job-summary.

func (*Action) Context

func (a *Action) Context(th *starlark.Thread, fn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

Context returns the GitHub Actions Context as a Starlark struct.

func (*Action) Debug

func (a *Action) Debug(th *starlark.Thread, fn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

Debug prints a debug-level message. See https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands#setting-a-debug-message.

The caller is expected to format the message using string interpolation with % operator, string.format method, or other means.

func (*Action) Error

func (a *Action) Error(th *starlark.Thread, fn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

Error prints a error-level message. See https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands#setting-an-error-message.

The caller is expected to format the message using string interpolation with % operator, string.format method, or other means.

func (*Action) Fatal

func (a *Action) Fatal(th *starlark.Thread, fn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

Fatal prints a message using [action.Error] and fails the Starlark thread.

The caller is expected to format the message using string interpolation with % operator, string.format method, or other means.

func (*Action) GetInput

func (a *Action) GetInput(th *starlark.Thread, fn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

GetInput gets the input by the given name. Returns the empty string if the input is not defined.

func (*Action) Group

func (a *Action) Group(th *starlark.Thread, fn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

Group starts a new collapsable region up to the next endgroup invocation. See https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands#grouping-log-lines.

func (*Action) Log

func (a *Action) Log(th *starlark.Thread, fn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

Log prints a message without level annotation.

The caller is expected to format the message using string interpolation with % operator, string.format method, or other means.

func (*Action) Notice

func (a *Action) Notice(th *starlark.Thread, fn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

Notice prints a notice-level message. See https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands#setting-a-notice-message.

The caller is expected to format the message using string interpolation with % operator, string.format method, or other means.

func (*Action) RemoveMatcher

func (a *Action) RemoveMatcher(th *starlark.Thread, fn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

RemoveMatcher removes a matcher with the given owner name.

func (*Action) SaveState

func (a *Action) SaveState(th *starlark.Thread, fn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

SaveState saves state to be used in the "finally" post job entry point. See https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands#sending-values-to-the-pre-and-post-actions.

func (*Action) Warning

func (a *Action) Warning(th *starlark.Thread, fn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

Warning prints a warning-level message. See https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands#setting-a-warning-message.

The caller is expected to format the message using string interpolation with % operator, string.format method, or other means.

Jump to

Keyboard shortcuts

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