actions

package module
v0.5.12 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2019 License: Apache-2.0 Imports: 12 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

go-actions

dockeri.co

A collection of universally useful commands written in Go for GitHub v2 Actions.

Close gaps you might encounter while using GitHub Actions v2 for CI/CD and for running bots.

Use for as-is, or as a reference and source-of-inspiration of your own command.

Included commands

  • For PR checking bot: pullvet checks labels and milestones associated to each pull request for project management and compliance. A pullvet rule looks like accept only PR that does have at least one of these labels and one or more release notes in the description.
  • merge merges a PR when it is passing all the required status checks.
  • say adds a comment to an issue or a pull request that triggered the event.
  • rebase rebases the pull request onto the specified branch and force pushes it to the head branch
  • For CI/CD: exec runs an arbitrary command and updates GitHub "Check Run" and/or "Status" accordingly

Usage

TL;DR; Grab actions or sub-components like pullvet from releases and run it on GitHub Actions v2.

Although each command is buildable and available as a standalone application, there's also a "hyper" app called actions, which is also a standalone binary that is composed of multiple apps listed in the Included commands section:

$ actions
actions is a collection of usable commands for GitHub v2 Actions

Usage:
  actions [command]
Available Commands:
  pullvet	checks labels and milestones associated to each pull request for project management and compliance
  exec      runs an arbitrary command and updates GitHub "Check Run" and/or "Status" accordingly

Use "actions [command] --help" for more information about a command
Examples
Regexp-match pull request label(s)

Set pull request status named label to green only when it has a "size" label like "size/s":

actions exec -status-context label -- actions pullvet -label-match 'size/.+'
Regexp-match pull request milestone or alternative label

Set pull request status named milestone to green only when it has a milestone titled like "test-v1", or a label "milestone/none" to express there's exactly no milestone associated:

actions exec -status-context milestone -- actions pullvet -require-any -milestone-match 'test-v.+' label milestone/none
GitHub Actions

Provide GITHUB_TOKEN as you usually do on GitHub Actions:

name: pullvet
on:
  pull_request:
    types: [opened, reopened, edited, milestoned, demilestoned, labeled, unlabeled, synchronize ]
jobs:
  pullvet:
    runs-on: ubuntu-latest
    steps:
    - uses: docker://variantdev/actions:latest
      with:
        args: pullvet -require-any -label releasenote/none -note releasenote
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Developing

Run make build to build bin/actions:

$ make build
$ bin/actions
actions A collection of usable commands for GitHub v2 Actions

Usage:
  actions [command]
Available Commands:
  pullvet	checks labels and milestones associated to each pull request for project management and compliance

Use "actions [command] --help" for more information about a command

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckRunEvent

func CheckRunEvent() (*github.CheckRunEvent, error)

func CheckSuiteEvent

func CheckSuiteEvent() (*github.CheckSuiteEvent, error)

func CreateClient

func CreateClient(instToken, baseURL, uploadURL string) (*github.Client, error)

CreateClient uses either of the belows to authenticate to the Github API: - installation toke: `"token " + os.Getenv("GITHUB_TOKEN")` - personal access token: `"bearer " + os.Getenv("GITHUB_TOKEN")`

func Event

func Event() []byte

func EventName

func EventName() string

func EventPath

func EventPath() string

func GetPullRequest

func GetPullRequest(issue *github.IssuesEvent) (*github.PullRequest, error)

func IssueEvent

func IssueEvent() (*github.IssuesEvent, error)

func IssueNumberOwnerRepo

func IssueNumberOwnerRepo() (int, string, string, error)

func ParseEvent

func ParseEvent() (interface{}, error)

func PullRequest

func PullRequest() (*github.PullRequest, string, string, error)

func PullRequestEvent

func PullRequestEvent() (*github.PullRequestEvent, error)

func RunCmd

func RunCmd(cmd string, args []string) (string, string, error)

Types

type StringSlice

type StringSlice []string

func (*StringSlice) Set

func (f *StringSlice) Set(value string) error

func (*StringSlice) String

func (f *StringSlice) String() string

Directories

Path Synopsis
cmd
checks command
exec command
pkg
cli
say

Jump to

Keyboard shortcuts

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