Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetToken ¶
GetToken gets the Github Actions token. See: https://docs.github.com/en/actions/security-guides/automatic-token-authentication
Types ¶
type OIDCClient ¶
type OIDCClient struct {
// contains filtered or unexported fields
}
OIDCClient is a client for the GitHub OIDC provider.
func NewOIDCClient ¶
func NewOIDCClient() (*OIDCClient, error)
NewOIDCClient returns new GitHub OIDC provider client.
func NewTestOIDCServer ¶
func NewTestOIDCServer(t *testing.T, now time.Time, token *OIDCToken) (*httptest.Server, *OIDCClient)
NewTestOIDCServer returns a httptest.Server that can be used as the OIDC server, and an OIDClient that will use the test server. The server returns the given token when queried. Now is the time used for token expiration verification by the client.
type OIDCToken ¶
type OIDCToken struct { // Issuer is the token issuer. Issuer string // Audience is the audience for which the token was granted. Audience []string // Expiry is the expiration date of the token. Expiry time.Time // JobWorkflowRef is a reference to the current job workflow. JobWorkflowRef string `json:"job_workflow_ref"` // RepositoryID is the unique repository ID. RepositoryID string `json:"repository_id"` // RepositoryOwnerID is the unique ID of the owner of the repository. RepositoryOwnerID string `json:"repository_owner_id"` // ActorID is the unique ID of the actor who triggered the build. ActorID string `json:"actor_id"` }
OIDCToken represents the contents of a GitHub OIDC JWT token.
type WorkflowContext ¶
type WorkflowContext struct { Repository string `json:"repository"` RepositoryOwner string `json:"repository_owner"` ActionPath string `json:"action_path"` Workflow string `json:"workflow"` EventName string `json:"event_name"` Event map[string]interface{} `json:"event"` SHA string `json:"sha"` RefType string `json:"ref_type"` Ref string `json:"ref"` BaseRef string `json:"base_ref"` HeadRef string `json:"head_ref"` Actor string `json:"actor"` RunNumber string `json:"run_number"` ServerURL string `json:"server_url"` RunID string `json:"run_id"` RunAttempt string `json:"run_attempt"` }
WorkflowContext is the `github` context given to workflows that contains information about the GitHub Actions workflow run.
See: https://docs.github.com/en/actions/learn-github-actions/contexts#github-context.
func GetWorkflowContext ¶
func GetWorkflowContext() (WorkflowContext, error)
GetWorkflowContext returns the current GitHub Actions 'github' context.
func (WorkflowContext) RepositoryURI ¶
func (c WorkflowContext) RepositoryURI() string
RepositoryURI returns a full repository URI for the repo that triggered the workflow.