gitlab.com/sparetimecoders/build-tools@v0.1.0/pkg/ci/github.go (about)

     1  package ci
     2  
     3  import (
     4  	"strings"
     5  )
     6  
     7  type Github struct {
     8  	*Common
     9  	CICommit     string `env:"GITHUB_SHA"`
    10  	CIBuildName  string `env:"RUNNER_WORKSPACE"`
    11  	CIBranchName string `env:"GITHUB_REF"`
    12  }
    13  
    14  var _ CI = &Github{}
    15  
    16  func (c *Github) Name() string {
    17  	return "Github"
    18  }
    19  
    20  func (c *Github) BranchReplaceSlash() string {
    21  	return branchReplaceSlash(c.Branch())
    22  }
    23  
    24  func (c *Github) BuildName() string {
    25  	return c.Common.BuildName(strings.TrimPrefix(c.CIBuildName, "/home/runner/work/"))
    26  }
    27  
    28  func (c *Github) Branch() string {
    29  	return c.Common.Branch(strings.TrimPrefix(c.CIBranchName, "refs/heads/"))
    30  }
    31  
    32  func (c *Github) Commit() string {
    33  	return c.Common.Commit(c.CICommit)
    34  }
    35  
    36  func (c *Github) Configured() bool {
    37  	return c.CIBuildName != ""
    38  }