Documentation
¶
Index ¶
- Constants
- func CompareGitFolderSHAs(repoPath, sha1, sha2 string) ([]string, error)
- func CompareGithubSHAs(client *github.Client, cfg *InputConfig, baseSHA string) ([]string, error)
- func Delta(repoPath string)
- func FilterStrings(input []string, includePatterns, excludePatterns []string) []string
- func GetClient(c *InputConfig) *github.Client
- func GetGitFolderBranchLatestSHA(repoPath, branchName string) (string, error)
- func GetGitHubBranchLatestSHA(client *github.Client, cfg *InputConfig) string
- func GetLatestSuccessfulDeploymentSha(client *github.Client, cfg *InputConfig) string
- func SetGitHubOutput(name, value string)
- type InputConfig
Constants ¶
const (
// FileSeparator is used to split the Files and IgnoreFiles strings into slices
FileSeparator = "\n"
)
Variables ¶
This section is empty.
Functions ¶
func CompareGitFolderSHAs ¶
CompareGitFolderSHAs retrieves the list of files that have changed between two commits identified by their SHAs. It takes the repository path and the two commit SHAs as input parameters. Returns a slice of strings containing the names of the changed files and an error if any occurs.
func CompareGithubSHAs ¶
CompareGithubSHAs compares the commits between the base SHA and the current SHA for the specified repository, and returns a list of the filenames that have changed.
client is the GitHub API client to use for the comparison. cfg is the input configuration containing the repository information and the current SHA. baseSHA is the base SHA to compare against.
Returns a slice of filenames that have changed between the base SHA and the current SHA. If an error occurs during the comparison, an error is returned.
func Delta ¶
func Delta(repoPath string)
Delta calculates the difference between the latest successful deployment SHA and the current SHA, and sets GitHub Actions output variables with the results. If there are any changes detected, the "is_detected" output is set to "true" and the "delta_files" output is set to a JSON-encoded list of the changed files. If there are no changes, the "is_detected" output is set to "false".
func FilterStrings ¶
FilterStrings filters the input strings based on inclusion and exclusion patterns using filepath.Match.
func GetClient ¶
func GetClient(c *InputConfig) *github.Client
GetClient creates a new GitHub client with the provided configuration.
func GetGitFolderBranchLatestSHA ¶
GetGitFolderBranchLatestSHA retrieves the latest commit of a given branch in a Git repository. It takes the repository path and the branch name as input parameters. Returns the commit hash as a string and an error if any occurs.
func GetGitHubBranchLatestSHA ¶
func GetGitHubBranchLatestSHA(client *github.Client, cfg *InputConfig) string
GetLatestSHA retrieves the latest commit SHA for a specified branch in a repository.
func GetLatestSuccessfulDeploymentSha ¶
func GetLatestSuccessfulDeploymentSha(client *github.Client, cfg *InputConfig) string
GetLatestSuccessfulDeploymentSha retrieves the Sha of latest successful deployment for a given environment
func SetGitHubOutput ¶
func SetGitHubOutput(name, value string)
SetGitHubOutput sets a GitHub Actions output variable.
Types ¶
type InputConfig ¶
type InputConfig struct { Environment string `env:"INPUT_ENVIRONMENT"` Commit string `env:"INPUT_COMMIT"` Includes string `env:"INPUT_INCLUDES"` Excludes string `env:"INPUT_EXCLUDES"` GithubToken string `env:"INPUT_GITHUB_TOKEN"` Sha string `env:"GITHUB_SHA"` Ref string `env:"GITHUB_REF"` ApiUrl string `env:"GITHUB_API_URL"` Workflow string `env:"GITHUB_WORKFLOW"` EventName string `env:"GITHUB_EVENT_NAME"` Job string `env:"GITHUB_JOB"` Repo string `env:"GITHUB_REPOSITORY"` Branch string `env:"INPUT_BRANCH"` IncludesPatterns []string ExcludesPatterns []string // contains filtered or unexported fields }
InputConfig holds the configuration for the Action Inputs
func GetInputConfig ¶
func GetInputConfig() InputConfig
GetInputConfig parses environment variables into an InputConfig struct and processes the Files and IgnoreFiles fields
func (*InputConfig) Validate ¶
func (c *InputConfig) Validate()
Validate checks if the required fields in InputConfig are set