Added branch filter.
This commit is contained in:
@@ -45,9 +45,12 @@ if (repoParts.Length != 2)
|
||||
string repoOwner = repoParts[0];
|
||||
string repoName = repoParts[1];
|
||||
|
||||
string workflowPattern = configuration["workflowPattern"] ?? string.Empty;
|
||||
string workflowPattern = configuration["workflowPattern"] ?? "*";
|
||||
Regex workflowRegex = WildcardToRegex(workflowPattern);
|
||||
|
||||
string branchPattern = configuration["branchPattern"] ?? "*";
|
||||
Regex branchRegex = WildcardToRegex(branchPattern);
|
||||
|
||||
string artifactPattern = configuration["artifactPattern"] ?? "*";
|
||||
Regex artifactRegex = WildcardToRegex(artifactPattern);
|
||||
|
||||
@@ -101,7 +104,16 @@ if (!getWorkflowRunsApiResponse.TryOk(out ActionWorkflowRunsResponse workflowRun
|
||||
return 1;
|
||||
}
|
||||
|
||||
ActionWorkflowRun? actionWorkflowRun = workflowRunResponse.WorkflowRuns.FirstOrDefault(w => workflowRegex.IsMatch(w.Path.Split('@')[0]));
|
||||
bool WorkflowMatchesBranch(ActionWorkflowRun workflowRun)
|
||||
{
|
||||
string[] pathParts = workflowRun.Path.Split('@');
|
||||
if (pathParts.Length < 2) return false;
|
||||
string workflowName = pathParts[0];
|
||||
string branch = pathParts[1];
|
||||
return workflowRegex.IsMatch(workflowName) && branchRegex.IsMatch(branch);
|
||||
}
|
||||
|
||||
ActionWorkflowRun? actionWorkflowRun = workflowRunResponse.WorkflowRuns.FirstOrDefault(WorkflowMatchesBranch);
|
||||
if (actionWorkflowRun is null)
|
||||
{
|
||||
Console.WriteLine("No matching workflow run found.");
|
||||
|
||||
Reference in New Issue
Block a user