cienv

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package cienv provides utility for environment variable in CI services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsInGitHubAction

func IsInGitHubAction() bool

IsInGitHubAction returns true if reviewdog is running in GitHub Actions.

Types

type BuildInfo

type BuildInfo struct {
	Owner string
	Repo  string
	SHA   string

	// Optional.
	PullRequest int // MergeRequest for GitLab.

	// Optional.
	Branch string
}

BuildInfo represents build information about GitHub or GitLab project.

func GetBuildInfo

func GetBuildInfo() (prInfo *BuildInfo, isPR bool, err error)

GetBuildInfo returns BuildInfo from environment variables.

Supported CI services' documents: - Travis CI: https://docs.travis-ci.com/user/environment-variables/ - Circle CI: https://circleci.com/docs/environment-variables/ - Drone.io: http://docs.drone.io/environment-reference/ - GitLab CI: https://docs.gitlab.com/ee/ci/variables/#predefined-variables-environment-variables - GitLab CI doesn't export ID of Merge Request. https://gitlab.com/gitlab-org/gitlab-ce/issues/15280

type GitHubEvent

type GitHubEvent struct {
	PullRequest GitHubPullRequest `json:"pull_request"`
	Repository  struct {
		Owner struct {
			Login string `json:"login"`
		} `json:"owner"`
		Name string `json:"name"`
	} `json:"repository"`
	CheckSuite struct {
		After        string              `json:"after"`
		PullRequests []GitHubPullRequest `json:"pull_requests"`
	} `json:"check_suite"`
	HeadCommit struct {
		ID string `json:"id"`
	} `json:"head_commit"`
}

https://help.github.com/en/articles/virtual-environments-for-github-actions#default-environment-variables

func LoadGitHubEvent

func LoadGitHubEvent() (*GitHubEvent, error)

LoadGitHubEvent loads GitHubEvent if it's running in GitHub Actions.

type GitHubPullRequest

type GitHubPullRequest struct {
	Number int `json:"number"`
	Head   struct {
		Sha  string `json:"sha"`
		Ref  string `json:"ref"`
		Repo struct {
			Fork bool `json:"fork"`
		} `json:"repo"`
	} `json:"head"`
}

Jump to

Keyboard shortcuts

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