diff --git a/plugins/scaffolder-backend-module-github/api-report.md b/plugins/scaffolder-backend-module-github/api-report.md index beabdfaaf6..94b642bdbf 100644 --- a/plugins/scaffolder-backend-module-github/api-report.md +++ b/plugins/scaffolder-backend-module-github/api-report.md @@ -77,6 +77,7 @@ export function createGithubEnvironmentAction(options: { } | undefined; customBranchPolicyNames?: string[] | undefined; + customTagPolicyNames?: string[] | undefined; environmentVariables?: | { [key: string]: string; diff --git a/plugins/scaffolder-backend-module-github/src/actions/githubEnvironment.examples.test.ts b/plugins/scaffolder-backend-module-github/src/actions/githubEnvironment.examples.test.ts index ecb4e9f092..9d4395eb7a 100644 --- a/plugins/scaffolder-backend-module-github/src/actions/githubEnvironment.examples.test.ts +++ b/plugins/scaffolder-backend-module-github/src/actions/githubEnvironment.examples.test.ts @@ -171,6 +171,7 @@ describe('github:environment:create examples', () => { repo: 'repository', environment_name: 'envname', name: 'main', + type: 'branch', }); expect( @@ -180,6 +181,7 @@ describe('github:environment:create examples', () => { repo: 'repository', environment_name: 'envname', name: '*.*.*', + type: 'branch', }); expect( diff --git a/plugins/scaffolder-backend-module-github/src/actions/githubEnvironment.test.ts b/plugins/scaffolder-backend-module-github/src/actions/githubEnvironment.test.ts index 16872525b4..a8d8c4ef2e 100644 --- a/plugins/scaffolder-backend-module-github/src/actions/githubEnvironment.test.ts +++ b/plugins/scaffolder-backend-module-github/src/actions/githubEnvironment.test.ts @@ -121,6 +121,7 @@ describe('github:environment:create', () => { }, }); }); + it('should work specify deploymentBranchPolicy custom', async () => { await action.handler({ ...mockContext, @@ -153,6 +154,7 @@ describe('github:environment:create', () => { repo: 'repository', environment_name: 'envname', name: 'main', + type: 'branch', }); expect( mockOctokit.rest.repos.createDeploymentBranchPolicy, @@ -161,6 +163,52 @@ describe('github:environment:create', () => { repo: 'repository', environment_name: 'envname', name: '*.*.*', + type: 'branch', + }); + }); + + it('should work specify deploymentTagPolicy custom', async () => { + await action.handler({ + ...mockContext, + input: { + ...mockContext.input, + deploymentBranchPolicy: { + protected_branches: false, + custom_branch_policies: true, + }, + customTagPolicyNames: ['main', '*.*.*'], + }, + }); + + expect( + mockOctokit.rest.repos.createOrUpdateEnvironment, + ).toHaveBeenCalledWith({ + owner: 'owner', + repo: 'repository', + environment_name: 'envname', + deployment_branch_policy: { + protected_branches: false, + custom_branch_policies: true, + }, + }); + + expect( + mockOctokit.rest.repos.createDeploymentBranchPolicy, + ).toHaveBeenCalledWith({ + owner: 'owner', + repo: 'repository', + environment_name: 'envname', + name: 'main', + type: 'tag', + }); + expect( + mockOctokit.rest.repos.createDeploymentBranchPolicy, + ).toHaveBeenCalledWith({ + owner: 'owner', + repo: 'repository', + environment_name: 'envname', + name: '*.*.*', + type: 'tag', }); });