Skip to content

Commit 48667b4

Browse files
committed
Fix creating secrets in github:environment:create action
Signed-off-by: Kamil Markow <kamilmarkow@gmail.com>
1 parent 998850c commit 48667b4

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

.changeset/quick-horses-reply.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@backstage/plugin-scaffolder-backend': patch
3+
---
4+
5+
Fix creating env secret in github:environment:create action

plugins/scaffolder-backend/src/scaffolder/actions/builtin/github/githubEnvironment.examples.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { examples } from './gitHubEnvironment.examples';
2525
const mockOctokit = {
2626
rest: {
2727
actions: {
28-
getRepoPublicKey: jest.fn(),
28+
getEnvironmentPublicKey: jest.fn(),
2929
createEnvironmentVariable: jest.fn(),
3030
createOrUpdateEnvironmentSecret: jest.fn(),
3131
},
@@ -68,7 +68,7 @@ describe('github:environment:create examples', () => {
6868
};
6969

7070
beforeEach(() => {
71-
mockOctokit.rest.actions.getRepoPublicKey.mockResolvedValue({
71+
mockOctokit.rest.actions.getEnvironmentPublicKey.mockResolvedValue({
7272
data: {
7373
key: publicKey,
7474
key_id: 'keyid',
@@ -109,7 +109,7 @@ describe('github:environment:create examples', () => {
109109
expect(
110110
mockOctokit.rest.actions.createEnvironmentVariable,
111111
).not.toHaveBeenCalled();
112-
expect(mockOctokit.rest.actions.getRepoPublicKey).not.toHaveBeenCalled();
112+
expect(mockOctokit.rest.actions.getEnvironmentPublicKey).not.toHaveBeenCalled();
113113
expect(
114114
mockOctokit.rest.actions.createOrUpdateEnvironmentSecret,
115115
).not.toHaveBeenCalled();
@@ -141,7 +141,7 @@ describe('github:environment:create examples', () => {
141141
expect(
142142
mockOctokit.rest.actions.createEnvironmentVariable,
143143
).not.toHaveBeenCalled();
144-
expect(mockOctokit.rest.actions.getRepoPublicKey).not.toHaveBeenCalled();
144+
expect(mockOctokit.rest.actions.getEnvironmentPublicKey).not.toHaveBeenCalled();
145145
expect(
146146
mockOctokit.rest.actions.createOrUpdateEnvironmentSecret,
147147
).not.toHaveBeenCalled();

plugins/scaffolder-backend/src/scaffolder/actions/builtin/github/githubEnvironment.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { ScmIntegrations } from '@backstage/integration';
2424
const mockOctokit = {
2525
rest: {
2626
actions: {
27-
getRepoPublicKey: jest.fn(),
27+
getEnvironmentPublicKey: jest.fn(),
2828
createEnvironmentVariable: jest.fn(),
2929
createOrUpdateEnvironmentSecret: jest.fn(),
3030
},
@@ -71,7 +71,7 @@ describe('github:environment:create', () => {
7171
};
7272

7373
beforeEach(() => {
74-
mockOctokit.rest.actions.getRepoPublicKey.mockResolvedValue({
74+
mockOctokit.rest.actions.getEnvironmentPublicKey.mockResolvedValue({
7575
data: {
7676
key: publicKey,
7777
key_id: 'keyid',

plugins/scaffolder-backend/src/scaffolder/actions/builtin/github/githubEnvironment.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,9 @@ export function createGithubEnvironmentAction(options: {
167167
}
168168

169169
if (secrets) {
170-
const publicKeyResponse = await client.rest.actions.getRepoPublicKey({
171-
owner: owner,
172-
repo: repo,
170+
const publicKeyResponse = await client.rest.actions.getEnvironmentPublicKey({
171+
repository_id: repository.data.id,
172+
environment_name: name,
173173
});
174174

175175
await Sodium.ready;

0 commit comments

Comments
 (0)