From ef21f88c6eb4c29da40d306ab6657196986d5994 Mon Sep 17 00:00:00 2001 From: Tanner Juedeman Date: Tue, 4 Feb 2025 14:33:30 -0600 Subject: [PATCH] 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) {