internal

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FileSeparator is used to split the Files and IgnoreFiles strings into slices
	FileSeparator = "\n"
)

Variables

This section is empty.

Functions

func CompareGitFolderSHAs

func CompareGitFolderSHAs(repoPath, sha1, sha2 string) ([]string, error)

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

func CompareGithubSHAs(client *github.Client, cfg *InputConfig, baseSHA string) ([]string, error)

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

func FilterStrings(input []string, includePatterns, excludePatterns []string) []string

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

func GetGitFolderBranchLatestSHA(repoPath, branchName string) (string, error)

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

Jump to

Keyboard shortcuts

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