All checks were successful
default / ensure tests work (push) Successful in 27s
33 lines
1.1 KiB
Go
33 lines
1.1 KiB
Go
// Package artifact provides a client for the GitHub Actions results service.
|
|
// The results service exposes the ArtifactService twirp API and the Azure
|
|
// block-blob storage used to upload and download workflow artifacts.
|
|
package artifact
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"code.geekeey.de/actions/sdk"
|
|
)
|
|
|
|
// Client talks to the results service. It authorizes every request with the
|
|
// action runtime token and resolves relative URLs against the results URL.
|
|
type Client struct {
|
|
http *sdk.Client
|
|
}
|
|
|
|
// NewClient returns a client that authenticates against the results service at
|
|
// base using the given runtime token.
|
|
func NewClient(base, runtimeToken string) *Client {
|
|
return &Client{http: sdk.NewClient(base, runtimeToken)}
|
|
}
|
|
|
|
// NewClientFromEnv returns a client configured from the ACTIONS_RESULTS_URL and
|
|
// ACTIONS_RUNTIME_TOKEN environment variables.
|
|
func NewClientFromEnv(env func(string) string) *Client {
|
|
return NewClient(env("ACTIONS_RESULTS_URL"), env("ACTIONS_RUNTIME_TOKEN"))
|
|
}
|
|
|
|
// Do implements the request executor used by the twirp methods.
|
|
func (c *Client) Do(req *http.Request) (*http.Response, error) {
|
|
return c.http.Do(req)
|
|
}
|