Added branch filter.
This commit is contained in:
@@ -25,10 +25,10 @@ inputs:
|
|||||||
description: "Pattern of the artifacts to match. Supports wildcard or RegEx. Default: *"
|
description: "Pattern of the artifacts to match. Supports wildcard or RegEx. Default: *"
|
||||||
required: true
|
required: true
|
||||||
default: "*"
|
default: "*"
|
||||||
artifactName:
|
branchPattern:
|
||||||
description: "Name of the artifact when it is downloaded. If not specified, the artifact will be named what the artifact is named."
|
description: "Branch of the workflow to match. Supports wildcard or RegEx. Default: ${{ github.ref }}"
|
||||||
required: false
|
required: false
|
||||||
default: ""
|
default: "${{ github.ref }}"
|
||||||
unzipDir:
|
unzipDir:
|
||||||
description: "Directory to unzip the artifacts into. If not specified, the artifacts will not be unzipped."
|
description: "Directory to unzip the artifacts into. If not specified, the artifacts will not be unzipped."
|
||||||
required: false
|
required: false
|
||||||
|
|||||||
@@ -45,9 +45,12 @@ if (repoParts.Length != 2)
|
|||||||
string repoOwner = repoParts[0];
|
string repoOwner = repoParts[0];
|
||||||
string repoName = repoParts[1];
|
string repoName = repoParts[1];
|
||||||
|
|
||||||
string workflowPattern = configuration["workflowPattern"] ?? string.Empty;
|
string workflowPattern = configuration["workflowPattern"] ?? "*";
|
||||||
Regex workflowRegex = WildcardToRegex(workflowPattern);
|
Regex workflowRegex = WildcardToRegex(workflowPattern);
|
||||||
|
|
||||||
|
string branchPattern = configuration["branchPattern"] ?? "*";
|
||||||
|
Regex branchRegex = WildcardToRegex(branchPattern);
|
||||||
|
|
||||||
string artifactPattern = configuration["artifactPattern"] ?? "*";
|
string artifactPattern = configuration["artifactPattern"] ?? "*";
|
||||||
Regex artifactRegex = WildcardToRegex(artifactPattern);
|
Regex artifactRegex = WildcardToRegex(artifactPattern);
|
||||||
|
|
||||||
@@ -101,7 +104,16 @@ if (!getWorkflowRunsApiResponse.TryOk(out ActionWorkflowRunsResponse workflowRun
|
|||||||
return 1;
|
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)
|
if (actionWorkflowRun is null)
|
||||||
{
|
{
|
||||||
Console.WriteLine("No matching workflow run found.");
|
Console.WriteLine("No matching workflow run found.");
|
||||||
|
|||||||
Reference in New Issue
Block a user