feat: support tag based policies

Signed-off-by: Christopher Diaz <codingdiaz@icloud.com>
This commit is contained in:
Christopher Diaz
2024-06-19 15:28:07 -04:00
parent a989433c98
commit bdcb2990b3
@@ -44,6 +44,7 @@ export function createGithubEnvironmentAction(options: {
custom_branch_policies: boolean;
};
customBranchPolicyNames?: string[];
customTagPolicyNames?: string[];
environmentVariables?: { [key: string]: string };
secrets?: { [key: string]: string };
token?: string;
@@ -94,6 +95,16 @@ export function createGithubEnvironmentAction(options: {
type: 'string',
},
},
customTagPolicyNames: {
title: 'Custom Tag Policy Name',
description: `The name pattern that tags must match in order to deploy to the environment.
Wildcard characters will not match /. For example, to match tags that begin with release/ and contain an additional single slash, use release/*/*. For more information about pattern matching syntax, see the Ruby File.fnmatch documentation.`,
type: 'array',
items: {
type: 'string',
},
},
environmentVariables: {
title: 'Environment Variables',
description: `Environment variables attached to the deployment environment`,
@@ -118,6 +129,7 @@ export function createGithubEnvironmentAction(options: {
name,
deploymentBranchPolicy,
customBranchPolicyNames,
customTagPolicyNames,
environmentVariables,
secrets,
token: providedToken,
@@ -153,6 +165,19 @@ export function createGithubEnvironmentAction(options: {
await client.rest.repos.createDeploymentBranchPolicy({
owner: owner,
repo: repo,
type: 'branch',
environment_name: name,
name: item,
});
}
}
if (customTagPolicyNames) {
for (const item of customTagPolicyNames) {
await client.rest.repos.createDeploymentBranchPolicy({
owner: owner,
repo: repo,
type: 'tag',
environment_name: name,
name: item,
});