From bb8302b200f95642a0e259124a4eb09ea609dd6c Mon Sep 17 00:00:00 2001 From: Tanner Juedeman Date: Mon, 27 Jan 2025 15:04:17 -0600 Subject: [PATCH 1/7] Adds createWhenEmpty option to publish:github:pull-request action Signed-off-by: Tanner Juedeman --- .changeset/hungry-cycles-hide.md | 5 + .../githubPullRequest.examples.test.ts | 58 +++++++-- .../src/actions/githubPullRequest.examples.ts | 45 +++++-- .../src/actions/githubPullRequest.test.ts | 115 ++++++++++++++++++ .../src/actions/githubPullRequest.ts | 16 ++- 5 files changed, 217 insertions(+), 22 deletions(-) create mode 100644 .changeset/hungry-cycles-hide.md diff --git a/.changeset/hungry-cycles-hide.md b/.changeset/hungry-cycles-hide.md new file mode 100644 index 0000000000..22c6360c14 --- /dev/null +++ b/.changeset/hungry-cycles-hide.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend-module-github': patch +--- + +Adds `createWhenEmpty` option to `publish:github:pull-request` action. diff --git a/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.examples.test.ts b/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.examples.test.ts index 26469dfcb4..fb2763db51 100644 --- a/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.examples.test.ts +++ b/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.examples.test.ts @@ -617,13 +617,7 @@ describe('publish:github:pull-request examples', () => { expect(mockContext.output).toHaveBeenCalledWith('pullRequestNumber', 123); }); - it('Create a pull request with all parameters', async () => { - mockDir.setContent({ - [workspacePath]: { - source: { 'foo.txt': 'Hello there!' }, - irrelevant: { 'bar.txt': 'Nothing to see here' }, - }, - }); + it('Does not create an empty pull request', async () => { const input = yaml.parse(examples[12].example).steps[0].input; await action.handler({ @@ -638,8 +632,56 @@ describe('publish:github:pull-request examples', () => { title: 'Create my new app', body: 'This PR is really good', head: 'new-app', - draft: true, + draft: undefined, + createWhenEmpty: false, + changes: [ + { + commit: 'Create my new app', + files: { + 'file.txt': { + content: Buffer.from('Hello there!').toString('base64'), + encoding: 'base64', + mode: '100644', + }, + }, + }, + ], + }); + + expect(fakeClient.rest.pulls.requestReviewers).not.toHaveBeenCalled(); + expect(mockContext.output).toHaveBeenCalledTimes(3); + expect(mockContext.output).toHaveBeenCalledWith('targetBranchName', 'main'); + expect(mockContext.output).toHaveBeenCalledWith( + 'remoteUrl', + 'https://github.com/myorg/myrepo/pull/123', + ); + expect(mockContext.output).toHaveBeenCalledWith('pullRequestNumber', 123); + }); + + it('Create a pull request with all parameters', async () => { + mockDir.setContent({ + [workspacePath]: { + source: { 'foo.txt': 'Hello there!' }, + irrelevant: { 'bar.txt': 'Nothing to see here' }, + }, + }); + const input = yaml.parse(examples[13].example).steps[0].input; + + await action.handler({ + ...mockContext, + workspacePath, + input, + }); + + expect(fakeClient.createPullRequest).toHaveBeenCalledWith({ + owner: 'owner', + repo: 'repo', + title: 'Create my new app', + body: 'This PR is really good', + head: 'new-app', base: 'test', + draft: true, + createWhenEmpty: true, changes: [ { commit: 'Commit for foo changes', diff --git a/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.examples.ts b/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.examples.ts index b6d31e732b..e35e6d9a81 100644 --- a/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.examples.ts +++ b/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.examples.ts @@ -23,7 +23,7 @@ export const examples: TemplateExample[] = [ steps: [ { action: 'publish:github:pull-request', - name: 'Create a pull reuqest', + name: 'Create a pull request', input: { repoUrl: 'github.com?repo=repo&owner=owner', branchName: 'new-app', @@ -40,7 +40,7 @@ export const examples: TemplateExample[] = [ steps: [ { action: 'publish:github:pull-request', - name: 'Create a pull reuqest with target branch name', + name: 'Create a pull request with target branch name', input: { repoUrl: 'github.com?repo=repo&owner=owner', branchName: 'new-app', @@ -58,7 +58,7 @@ export const examples: TemplateExample[] = [ steps: [ { action: 'publish:github:pull-request', - name: 'Create a pull reuqest as draft', + name: 'Create a pull request as draft', input: { repoUrl: 'github.com?repo=repo&owner=owner', branchName: 'new-app', @@ -76,7 +76,7 @@ export const examples: TemplateExample[] = [ steps: [ { action: 'publish:github:pull-request', - name: 'Create a pull reuqest with target path', + name: 'Create a pull request with target path', input: { repoUrl: 'github.com?repo=repo&owner=owner', branchName: 'new-app', @@ -94,7 +94,7 @@ export const examples: TemplateExample[] = [ steps: [ { action: 'publish:github:pull-request', - name: 'Create a pull reuqest with source path', + name: 'Create a pull request with source path', input: { repoUrl: 'github.com?repo=repo&owner=owner', branchName: 'new-app', @@ -112,7 +112,7 @@ export const examples: TemplateExample[] = [ steps: [ { action: 'publish:github:pull-request', - name: 'Create a pull reuqest', + name: 'Create a pull request', input: { repoUrl: 'github.com?repo=repo&owner=owner', branchName: 'new-app', @@ -130,7 +130,7 @@ export const examples: TemplateExample[] = [ steps: [ { action: 'publish:github:pull-request', - name: 'Create a pull reuqest with reviewers', + name: 'Create a pull request with reviewers', input: { repoUrl: 'github.com?repo=repo&owner=owner', branchName: 'new-app', @@ -148,7 +148,7 @@ export const examples: TemplateExample[] = [ steps: [ { action: 'publish:github:pull-request', - name: 'Create a pull reuqest with team reviewers', + name: 'Create a pull request with team reviewers', input: { repoUrl: 'github.com?repo=repo&owner=owner', branchName: 'new-app', @@ -166,7 +166,7 @@ export const examples: TemplateExample[] = [ steps: [ { action: 'publish:github:pull-request', - name: 'Create a pull reuqest', + name: 'Create a pull request', input: { repoUrl: 'github.com?repo=repo&owner=owner', branchName: 'new-app', @@ -184,7 +184,7 @@ export const examples: TemplateExample[] = [ steps: [ { action: 'publish:github:pull-request', - name: 'Create a pull reuqest', + name: 'Create a pull request', input: { repoUrl: 'github.com?repo=repo&owner=owner', branchName: 'new-app', @@ -203,7 +203,7 @@ export const examples: TemplateExample[] = [ steps: [ { action: 'publish:github:pull-request', - name: 'Create a pull reuqest', + name: 'Create a pull request', input: { repoUrl: 'github.com?repo=repo&owner=owner', branchName: 'new-app', @@ -223,7 +223,7 @@ export const examples: TemplateExample[] = [ steps: [ { action: 'publish:github:pull-request', - name: 'Create a pull reuqest', + name: 'Create a pull request', input: { repoUrl: 'github.com?repo=repo&owner=owner', branchName: 'new-app', @@ -237,13 +237,31 @@ export const examples: TemplateExample[] = [ ], }), }, + { + description: 'Do not create empty pull request', + example: yaml.stringify({ + steps: [ + { + action: 'publish:github:pull-request', + name: 'Create a pull request', + input: { + repoUrl: 'github.com?repo=repo&owner=owner', + branchName: 'new-app', + title: 'Create my new app', + description: 'This PR is really good', + createWhenEmpty: false, + }, + }, + ], + }), + }, { description: 'Create a pull request with all parameters', example: yaml.stringify({ steps: [ { action: 'publish:github:pull-request', - name: 'Create a pull reuqest', + name: 'Create a pull request', input: { repoUrl: 'github.com?repo=repo&owner=owner', branchName: 'new-app', @@ -259,6 +277,7 @@ export const examples: TemplateExample[] = [ commitMessage: 'Commit for foo changes', gitAuthorName: 'Foo Bar', gitAuthorEmail: 'foo@bar.example', + createWhenEmpty: true, }, }, ], diff --git a/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.test.ts b/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.test.ts index ccb1efa29b..9133b0d300 100644 --- a/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.test.ts +++ b/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.test.ts @@ -1062,4 +1062,119 @@ describe('createPublishGithubPullRequestAction', () => { }); }); }); + + describe('with createWhenEmpty equals true', () => { + let input: GithubPullRequestActionInput; + let ctx: ActionContext; + + beforeEach(() => { + input = { + repoUrl: 'github.com?owner=myorg&repo=myrepo', + title: 'Create my new app', + branchName: 'new-app', + description: 'This PR is really good', + createWhenEmpty: true, + }; + + mockDir.setContent({ + [workspacePath]: { 'file.txt': 'Hello there!' }, + }); + + ctx = createMockActionContext({ input, workspacePath }); + }); + it('creates a pull request', async () => { + await instance.handler(ctx); + + expect(fakeClient.createPullRequest).toHaveBeenCalledWith({ + owner: 'myorg', + repo: 'myrepo', + title: 'Create my new app', + head: 'new-app', + body: 'This PR is really good', + createWhenEmpty: true, + changes: [ + { + commit: 'Create my new app', + files: { + 'file.txt': { + content: Buffer.from('Hello there!').toString('base64'), + encoding: 'base64', + mode: '100644', + }, + }, + }, + ], + }); + }); + + it('creates outputs for the pull request url and number', async () => { + await instance.handler(ctx); + + expect(ctx.output).toHaveBeenCalledWith( + 'remoteUrl', + 'https://github.com/myorg/myrepo/pull/123', + ); + expect(ctx.output).toHaveBeenCalledWith('pullRequestNumber', 123); + }); + + it('throws when creating a pull request fails', async () => { + fakeClient.createPullRequest.mockResolvedValueOnce(null); + + await expect(instance.handler(ctx)).rejects.toThrow( + 'null response from Github', + ); + }); + }); + + describe('with createWhenEmpty equals false', () => { + let input: GithubPullRequestActionInput; + let ctx: ActionContext; + + beforeEach(() => { + fakeClient.createPullRequest.mockResolvedValueOnce(null); + input = { + repoUrl: 'github.com?owner=myorg&repo=myrepo', + title: 'Create my new app', + branchName: 'new-app', + description: 'This PR is really good', + createWhenEmpty: false, + }; + + mockDir.setContent({ + [workspacePath]: { 'file.txt': 'Hello there!' }, + }); + + ctx = createMockActionContext({ input, workspacePath }); + }); + it('creates a pull request', async () => { + await instance.handler(ctx); + + expect(fakeClient.createPullRequest).toHaveBeenCalledWith({ + owner: 'myorg', + repo: 'myrepo', + title: 'Create my new app', + head: 'new-app', + body: 'This PR is really good', + createWhenEmpty: false, + changes: [ + { + commit: 'Create my new app', + files: { + 'file.txt': { + content: Buffer.from('Hello there!').toString('base64'), + encoding: 'base64', + mode: '100644', + }, + }, + }, + ], + }); + }); + + it('does not create outputs for the pull request url and number', async () => { + await instance.handler(ctx); + + expect(ctx.output).not.toHaveBeenCalled(); + }); + }); }); diff --git a/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.ts b/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.ts index 44830b3047..2f3662328d 100644 --- a/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.ts +++ b/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.ts @@ -145,6 +145,7 @@ export const createPublishGithubPullRequestAction = ( gitAuthorName?: string; gitAuthorEmail?: string; forceEmptyGitAuthor?: boolean; + createWhenEmpty?: boolean; }>({ id: 'publish:github:pull-request', examples, @@ -251,10 +252,16 @@ export const createPublishGithubPullRequestAction = ( description: 'Forces the author to be empty. This is useful when using a Github App, it permit the commit to be verified on Github', }, + createWhenEmpty: { + type: 'boolean', + title: 'Create When Empty', + description: + 'Set whether to create pull request when there are no changes to commit. The default value is true', + }, }, }, output: { - required: ['remoteUrl'], + required: [], type: 'object', properties: { targetBranchName: { @@ -293,6 +300,7 @@ export const createPublishGithubPullRequestAction = ( gitAuthorEmail, gitAuthorName, forceEmptyGitAuthor, + createWhenEmpty, } = ctx.input; const { owner, repo, host } = parseRepoUrl(repoUrl, integrations); @@ -379,6 +387,7 @@ export const createPublishGithubPullRequestAction = ( draft, update, forceFork, + createWhenEmpty, }; const gitAuthorInfo = { @@ -417,6 +426,11 @@ export const createPublishGithubPullRequestAction = ( } const response = await client.createPullRequest(createOptions); + if (createWhenEmpty === false && !response) { + ctx.logger.info('No changes to commit, pull request was not created'); + return; + } + if (!response) { throw new GithubResponseError('null response from Github'); } From 5a0ff48ca237441866faae2be665555e7efb03f1 Mon Sep 17 00:00:00 2001 From: Tanner Juedeman Date: Mon, 27 Jan 2025 15:51:30 -0600 Subject: [PATCH 2/7] add api reports Signed-off-by: Tanner Juedeman --- plugins/scaffolder-backend-module-github/report.api.md | 1 + plugins/scaffolder-backend/report.api.md | 1 + 2 files changed, 2 insertions(+) diff --git a/plugins/scaffolder-backend-module-github/report.api.md b/plugins/scaffolder-backend-module-github/report.api.md index 476e8fde1e..7e8759db60 100644 --- a/plugins/scaffolder-backend-module-github/report.api.md +++ b/plugins/scaffolder-backend-module-github/report.api.md @@ -469,6 +469,7 @@ export const createPublishGithubPullRequestAction: ( gitAuthorName?: string | undefined; gitAuthorEmail?: string | undefined; forceEmptyGitAuthor?: boolean | undefined; + createWhenEmpty?: boolean | undefined; }, JsonObject >; diff --git a/plugins/scaffolder-backend/report.api.md b/plugins/scaffolder-backend/report.api.md index 8fe17d26f8..832ac15d61 100644 --- a/plugins/scaffolder-backend/report.api.md +++ b/plugins/scaffolder-backend/report.api.md @@ -345,6 +345,7 @@ export const createPublishGithubPullRequestAction: ( gitAuthorName?: string | undefined; gitAuthorEmail?: string | undefined; forceEmptyGitAuthor?: boolean | undefined; + createWhenEmpty?: boolean | undefined; }, JsonObject >; From 1e935f0afef1b46c665e5d9baf6b970553c47e07 Mon Sep 17 00:00:00 2001 From: Tanner Juedeman Date: Tue, 4 Feb 2025 14:31:13 -0600 Subject: [PATCH 3/7] Add conditional rendering of oneOf scaffolder action outputs on ActionsPage Signed-off-by: Tanner Juedeman --- .changeset/wise-cycles-sparkle.md | 6 ++ .../ActionsPage/ActionsPage.test.tsx | 57 +++++++++++++++++++ .../components/ActionsPage/ActionsPage.tsx | 10 +++- 3 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 .changeset/wise-cycles-sparkle.md diff --git a/.changeset/wise-cycles-sparkle.md b/.changeset/wise-cycles-sparkle.md new file mode 100644 index 0000000000..2412280b0c --- /dev/null +++ b/.changeset/wise-cycles-sparkle.md @@ -0,0 +1,6 @@ +--- +'@backstage/plugin-scaffolder-backend': patch +'@backstage/plugin-scaffolder': patch +--- + +Added conditional rendering of oneOf output schemas on the Installed Actions page for scaffolder actions diff --git a/plugins/scaffolder/src/components/ActionsPage/ActionsPage.test.tsx b/plugins/scaffolder/src/components/ActionsPage/ActionsPage.test.tsx index acfdabac5b..a3b3049beb 100644 --- a/plugins/scaffolder/src/components/ActionsPage/ActionsPage.test.tsx +++ b/plugins/scaffolder/src/components/ActionsPage/ActionsPage.test.tsx @@ -125,6 +125,63 @@ describe('TemplatePage', () => { expect(rendered.getByText('Test output')).toBeInTheDocument(); }); + it('renders action with oneOf output', async () => { + scaffolderApiMock.listActions.mockResolvedValue([ + { + id: 'test', + description: 'example description', + schema: { + input: { + type: 'object', + required: ['foobar'], + properties: { + foobar: { + title: 'Test title', + type: 'string', + }, + }, + }, + output: { + oneOf: [ + { + type: 'object', + properties: { + buzz: { + title: 'Test output1', + type: 'string', + }, + }, + }, + { + type: 'object', + properties: { + buzz: { + title: 'Test output2', + type: 'string', + }, + }, + }, + ], + }, + }, + }, + ]); + const rendered = await renderInTestApp( + + + , + { + mountedRoutes: { + '/create/actions': rootRouteRef, + }, + }, + ); + expect(rendered.getByText('oneOf')).toBeInTheDocument(); + expect(rendered.getByText('Test title')).toBeInTheDocument(); + expect(rendered.getByText('Test output1')).toBeInTheDocument(); + expect(rendered.getByText('Test output2')).toBeInTheDocument(); + }); + it('renders action with multiple input types', async () => { scaffolderApiMock.listActions.mockResolvedValue([ { diff --git a/plugins/scaffolder/src/components/ActionsPage/ActionsPage.tsx b/plugins/scaffolder/src/components/ActionsPage/ActionsPage.tsx index f85c1f0e6b..50f7726202 100644 --- a/plugins/scaffolder/src/components/ActionsPage/ActionsPage.tsx +++ b/plugins/scaffolder/src/components/ActionsPage/ActionsPage.tsx @@ -340,11 +340,16 @@ export const ActionPageContent = () => { return undefined; } - const oneOf = renderTables( + const oneOfInput = renderTables( 'oneOf', `${action.id}.input`, action.schema?.input?.oneOf, ); + const oneOfOutput = renderTables( + 'oneOf', + `${action.id}.output`, + action.schema?.output?.oneOf, + ); return ( @@ -374,7 +379,7 @@ export const ActionPageContent = () => { {renderTable( formatRows(`${action.id}.input`, action?.schema?.input), )} - {oneOf} + {oneOfInput} )} {action.schema?.output && ( @@ -385,6 +390,7 @@ export const ActionPageContent = () => { {renderTable( formatRows(`${action.id}.output`, action?.schema?.output), )} + {oneOfOutput} )} {action.examples && ( From ef21f88c6eb4c29da40d306ab6657196986d5994 Mon Sep 17 00:00:00 2001 From: Tanner Juedeman Date: Tue, 4 Feb 2025 14:33:30 -0600 Subject: [PATCH 4/7] Add oneOf output subschema to publish:github:pull-request action Signed-off-by: Tanner Juedeman --- .changeset/thick-moose-do.md | 5 ++ .../src/actions/githubPullRequest.ts | 58 +++++++++++++------ 2 files changed, 46 insertions(+), 17 deletions(-) create mode 100644 .changeset/thick-moose-do.md diff --git a/.changeset/thick-moose-do.md b/.changeset/thick-moose-do.md new file mode 100644 index 0000000000..b3904272fb --- /dev/null +++ b/.changeset/thick-moose-do.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend-module-github': patch +--- + +Added oneOf output schema to publish:github:pull-request scaffolder action to allow for non-breaking addition of createWhenEmpty option diff --git a/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.ts b/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.ts index 2f3662328d..f192b61e39 100644 --- a/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.ts +++ b/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.ts @@ -256,29 +256,53 @@ export const createPublishGithubPullRequestAction = ( type: 'boolean', title: 'Create When Empty', description: - 'Set whether to create pull request when there are no changes to commit. The default value is true', + 'Set whether to create pull request when there are no changes to commit. The default value is true. If set to false, remoteUrl is no longer a required output.', }, }, }, output: { - required: [], - type: 'object', - properties: { - targetBranchName: { - title: 'Target branch name of the merge request', - type: 'string', + oneOf: [ + { + required: ['remoteUrl'], + type: 'object', + properties: { + targetBranchName: { + title: 'Target branch name of the merge request', + type: 'string', + }, + remoteUrl: { + type: 'string', + title: 'Pull Request URL', + description: 'Link to the pull request in Github', + }, + pullRequestNumber: { + type: 'number', + title: 'Pull Request Number', + description: 'The pull request number', + }, + }, }, - remoteUrl: { - type: 'string', - title: 'Pull Request URL', - description: 'Link to the pull request in Github', + { + required: [], + type: 'object', + properties: { + targetBranchName: { + title: 'Target branch name of the merge request', + type: 'string', + }, + remoteUrl: { + type: 'string', + title: 'Pull Request URL', + description: 'Link to the pull request in Github', + }, + pullRequestNumber: { + type: 'number', + title: 'Pull Request Number', + description: 'The pull request number', + }, + }, }, - pullRequestNumber: { - type: 'number', - title: 'Pull Request Number', - description: 'The pull request number', - }, - }, + ], }, }, async handler(ctx) { From a405de92907741878b5d1e2e1f8ba1c350013283 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Tue, 11 Feb 2025 11:42:18 +0100 Subject: [PATCH 5/7] Update .changeset/thick-moose-do.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .changeset/thick-moose-do.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/thick-moose-do.md b/.changeset/thick-moose-do.md index b3904272fb..eecf9c0333 100644 --- a/.changeset/thick-moose-do.md +++ b/.changeset/thick-moose-do.md @@ -2,4 +2,4 @@ '@backstage/plugin-scaffolder-backend-module-github': patch --- -Added oneOf output schema to publish:github:pull-request scaffolder action to allow for non-breaking addition of createWhenEmpty option +Added `oneOf` output schema to `publish:github:pull-request` scaffolder action to allow for non-breaking addition of `createWhenEmpty` option From 817dfd1f86d934867bd9089af0139596af3bfc67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Tue, 11 Feb 2025 11:42:24 +0100 Subject: [PATCH 6/7] Update .changeset/wise-cycles-sparkle.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .changeset/wise-cycles-sparkle.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/wise-cycles-sparkle.md b/.changeset/wise-cycles-sparkle.md index 2412280b0c..1605211caa 100644 --- a/.changeset/wise-cycles-sparkle.md +++ b/.changeset/wise-cycles-sparkle.md @@ -3,4 +3,4 @@ '@backstage/plugin-scaffolder': patch --- -Added conditional rendering of oneOf output schemas on the Installed Actions page for scaffolder actions +Added conditional rendering of `oneOf` output schemas on the Installed Actions page for scaffolder actions From 75617053fa5cf38d3096fed9aab343f08d03b1fd Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 11 Feb 2025 14:47:33 +0100 Subject: [PATCH 7/7] chore: revert the oneOf changes Signed-off-by: blam --- .changeset/hungry-cycles-hide.md | 4 +- .changeset/thick-moose-do.md | 5 -- .../src/actions/githubPullRequest.ts | 56 ++++++------------- 3 files changed, 18 insertions(+), 47 deletions(-) delete mode 100644 .changeset/thick-moose-do.md diff --git a/.changeset/hungry-cycles-hide.md b/.changeset/hungry-cycles-hide.md index 22c6360c14..55a5179029 100644 --- a/.changeset/hungry-cycles-hide.md +++ b/.changeset/hungry-cycles-hide.md @@ -1,5 +1,5 @@ --- -'@backstage/plugin-scaffolder-backend-module-github': patch +'@backstage/plugin-scaffolder-backend-module-github': minor --- -Adds `createWhenEmpty` option to `publish:github:pull-request` action. +**BREAKING**: The `remoteUrl` output is no longer required, it can be empty only when using the new `createWhenEmpty` boolean flag. diff --git a/.changeset/thick-moose-do.md b/.changeset/thick-moose-do.md deleted file mode 100644 index eecf9c0333..0000000000 --- a/.changeset/thick-moose-do.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@backstage/plugin-scaffolder-backend-module-github': patch ---- - -Added `oneOf` output schema to `publish:github:pull-request` scaffolder action to allow for non-breaking addition of `createWhenEmpty` option diff --git a/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.ts b/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.ts index f192b61e39..c9a1b3d1b5 100644 --- a/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.ts +++ b/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.ts @@ -261,48 +261,24 @@ export const createPublishGithubPullRequestAction = ( }, }, output: { - oneOf: [ - { - required: ['remoteUrl'], - type: 'object', - properties: { - targetBranchName: { - title: 'Target branch name of the merge request', - type: 'string', - }, - remoteUrl: { - type: 'string', - title: 'Pull Request URL', - description: 'Link to the pull request in Github', - }, - pullRequestNumber: { - type: 'number', - title: 'Pull Request Number', - description: 'The pull request number', - }, - }, + required: [], + type: 'object', + properties: { + targetBranchName: { + title: 'Target branch name of the merge request', + type: 'string', }, - { - required: [], - type: 'object', - properties: { - targetBranchName: { - title: 'Target branch name of the merge request', - type: 'string', - }, - remoteUrl: { - type: 'string', - title: 'Pull Request URL', - description: 'Link to the pull request in Github', - }, - pullRequestNumber: { - type: 'number', - title: 'Pull Request Number', - description: 'The pull request number', - }, - }, + remoteUrl: { + type: 'string', + title: 'Pull Request URL', + description: 'Link to the pull request in Github', }, - ], + pullRequestNumber: { + type: 'number', + title: 'Pull Request Number', + description: 'The pull request number', + }, + }, }, }, async handler(ctx) {