go-githubactions: github.com/sethvargo/go-githubactions Index | Examples | Files

package githubactions

import "github.com/sethvargo/go-githubactions"

Package githubactions provides an SDK for authoring GitHub Actions in Go. It has no external dependencies and provides a Go-like interface for interacting with GitHub Actions' build system.

Index

Examples

Package Files

actions.go actions_root.go

func AddMask Uses

func AddMask(p string)

AddMask adds a new field mask for the given string "p". After called, future attempts to log "p" will be replaced with "***" in log output.

func AddMatcher Uses

func AddMatcher(p string)

AddMatcher adds a new matcher with the given file path.

func AddPath Uses

func AddPath(p string)

AddPath adds the string "p" to the path for the invocation.

func Debugf Uses

func Debugf(msg string, args ...interface{})

Debugf prints a debug-level message. The arguments follow the standard Printf arguments.

func EndGroup Uses

func EndGroup()

EndGroup ends the current group.

func Errorf Uses

func Errorf(msg string, args ...interface{})

Errorf prints a error-level message. The arguments follow the standard Printf arguments.

func Fatalf Uses

func Fatalf(msg string, args ...interface{})

Fatalf prints a error-level message and exits. This is equivalent to Errorf followed by os.Exit(1).

func GetInput Uses

func GetInput(i string) string

GetInput gets the input by the given name.

func Group Uses

func Group(t string)

Group starts a new collapsable region up to the next ungroup invocation.

func RemoveMatcher Uses

func RemoveMatcher(o string)

RemoveMatcher removes a matcher with the given owner name.

func SaveState Uses

func SaveState(k, v string)

SaveState saves state to be used in the "finally" post job entry point.

func SetEnv Uses

func SetEnv(k, v string)

SetEnv sets an environment variable.

func SetOutput Uses

func SetOutput(k, v string)

SetOutput sets an output parameter.

func Warningf Uses

func Warningf(msg string, args ...interface{})

Warningf prints a warning-level message. The arguments follow the standard Printf arguments.

type Action Uses

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

Action is an internal wrapper around GitHub Actions' output and magic strings.

func New Uses

func New() *Action

New creates a new wrapper with helpers for outputting information in GitHub actions format.

Code:

a = githubactions.New()

func NewWithWriter Uses

func NewWithWriter(w io.Writer) *Action

NewWithWriter creates a wrapper using the given writer. This is useful for tests. The given writer cannot add any prefixes to the string, since GitHub requires these special strings to match a very particular format.

func WithFieldsMap Uses

func WithFieldsMap(m map[string]string) *Action

WithFieldsMap includes the provided fields in log output. The fields in "m" are automatically converted to k=v pairs and sorted.

func WithFieldsSlice Uses

func WithFieldsSlice(f []string) *Action

WithFieldsSlice includes the provided fields in log output. "f" must be a slice of k=v pairs. The given slice will be sorted.

func (*Action) AddMask Uses

func (c *Action) AddMask(p string)

AddMask adds a new field mask for the given string "p". After called, future attempts to log "p" will be replaced with "***" in log output.

Code:

a := githubactions.New()
a.AddMask("my-password")

func (*Action) AddMatcher Uses

func (c *Action) AddMatcher(p string)

AddMatcher adds a new matcher with the given file path.

func (*Action) AddPath Uses

func (c *Action) AddPath(p string)

AddPath adds the string "p" to the path for the invocation.

Code:

a := githubactions.New()
a.AddPath("/tmp/myapp")

func (*Action) Debugf Uses

func (c *Action) Debugf(msg string, args ...interface{})

Debugf prints a debug-level message. The arguments follow the standard Printf arguments.

Code:

a := githubactions.New()
a.Debugf("a debug message")

Code:

a := githubactions.New()
m := map[string]string{
    "file": "app.go",
    "line": "100",
}
a.WithFieldsMap(m).Debugf("a debug message")

Code:

a := githubactions.New()
s := []string{"file=app.go", "line=100"}
a.WithFieldsSlice(s).Debugf("a debug message")

func (*Action) EndGroup Uses

func (c *Action) EndGroup()

EndGroup ends the current group.

func (*Action) Errorf Uses

func (c *Action) Errorf(msg string, args ...interface{})

Errorf prints a error-level message. The arguments follow the standard Printf arguments.

Code:

a := githubactions.New()
a.Errorf("an error message")

Code:

a := githubactions.New()
m := map[string]string{
    "file": "app.go",
    "line": "100",
}
a.WithFieldsMap(m).Errorf("an error message")

Code:

a := githubactions.New()
s := []string{"file=app.go", "line=100"}
a.WithFieldsSlice(s).Errorf("an error message")

func (*Action) Fatalf Uses

func (c *Action) Fatalf(msg string, args ...interface{})

Fatalf prints a error-level message and exits. This is equivalent to Errorf followed by os.Exit(1).

func (*Action) GetInput Uses

func (c *Action) GetInput(i string) string

GetInput gets the input by the given name.

func (*Action) Group Uses

func (c *Action) Group(t string)

Group starts a new collapsable region up to the next ungroup invocation.

func (*Action) RemoveMatcher Uses

func (c *Action) RemoveMatcher(o string)

RemoveMatcher removes a matcher with the given owner name.

func (*Action) SaveState Uses

func (c *Action) SaveState(k, v string)

SaveState saves state to be used in the "finally" post job entry point.

func (*Action) SetEnv Uses

func (c *Action) SetEnv(k, v string)

SetEnv sets an environment variable.

Code:

a := githubactions.New()
a.SetEnv("MY_THING", "my value")

func (*Action) SetOutput Uses

func (c *Action) SetOutput(k, v string)

SetOutput sets an output parameter.

Code:

a := githubactions.New()
a.SetOutput("filepath", "/tmp/file-xyz1234")

func (*Action) Warningf Uses

func (c *Action) Warningf(msg string, args ...interface{})

Warningf prints a warning-level message. The arguments follow the standard Printf arguments.

Code:

a := githubactions.New()
a.Warningf("a warning message")

Code:

a := githubactions.New()
m := map[string]string{
    "file": "app.go",
    "line": "100",
}
a.WithFieldsMap(m).Warningf("a warning message")

Code:

a := githubactions.New()
s := []string{"file=app.go", "line=100"}
a.WithFieldsSlice(s).Warningf("a warning message")

func (*Action) WithFieldsMap Uses

func (c *Action) WithFieldsMap(m map[string]string) *Action

WithFieldsMap includes the provided fields in log output. The fields in "m" are automatically converted to k=v pairs and sorted.

func (*Action) WithFieldsSlice Uses

func (c *Action) WithFieldsSlice(f []string) *Action

WithFieldsSlice includes the provided fields in log output. "f" must be a slice of k=v pairs. The given slice will be sorted.

Package githubactions imports 5 packages (graph). Updated 2020-08-20. Refresh now. Tools for package owners.