Merge pull request #22520 from arodski/force-fork-flag
add forcefork input to github pull request action
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-scaffolder-backend-module-github': minor
|
||||
---
|
||||
|
||||
Allow to force the creation of a pull request from a forked repository
|
||||
@@ -375,6 +375,7 @@ export const createPublishGithubPullRequestAction: (
|
||||
teamReviewers?: string[] | undefined;
|
||||
commitMessage?: string | undefined;
|
||||
update?: boolean | undefined;
|
||||
forceFork?: boolean | undefined;
|
||||
},
|
||||
JsonObject
|
||||
>;
|
||||
|
||||
@@ -687,4 +687,57 @@ describe('createPublishGithubPullRequestAction', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('with force fork', () => {
|
||||
let input: GithubPullRequestActionInput;
|
||||
let ctx: ActionContext<GithubPullRequestActionInput>;
|
||||
|
||||
beforeEach(() => {
|
||||
input = {
|
||||
repoUrl: 'github.com?owner=myorg&repo=myrepo',
|
||||
title: 'Create my new app',
|
||||
branchName: 'new-app',
|
||||
description: 'This PR is really good',
|
||||
forceFork: true,
|
||||
};
|
||||
|
||||
mockDir.setContent({
|
||||
[workspacePath]: { 'file.txt': 'Hello there!' },
|
||||
});
|
||||
|
||||
ctx = {
|
||||
createTemporaryDirectory: jest.fn(),
|
||||
output: jest.fn(),
|
||||
logger: getRootLogger(),
|
||||
logStream: new Writable(),
|
||||
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',
|
||||
changes: [
|
||||
{
|
||||
commit: 'Create my new app',
|
||||
files: {
|
||||
'file.txt': {
|
||||
content: Buffer.from('Hello there!').toString('base64'),
|
||||
encoding: 'base64',
|
||||
mode: '100644',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
forceFork: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -135,6 +135,7 @@ export const createPublishGithubPullRequestAction = (
|
||||
teamReviewers?: string[];
|
||||
commitMessage?: string;
|
||||
update?: boolean;
|
||||
forceFork?: boolean;
|
||||
}>({
|
||||
id: 'publish:github:pull-request',
|
||||
examples,
|
||||
@@ -217,6 +218,11 @@ export const createPublishGithubPullRequestAction = (
|
||||
title: 'Update',
|
||||
description: 'Update pull request if already exists',
|
||||
},
|
||||
forceFork: {
|
||||
type: 'boolean',
|
||||
title: 'Force Fork',
|
||||
description: 'Create pull request from a fork',
|
||||
},
|
||||
},
|
||||
},
|
||||
output: {
|
||||
@@ -255,6 +261,7 @@ export const createPublishGithubPullRequestAction = (
|
||||
teamReviewers,
|
||||
commitMessage,
|
||||
update,
|
||||
forceFork,
|
||||
} = ctx.input;
|
||||
|
||||
const { owner, repo, host } = parseRepoUrl(repoUrl, integrations);
|
||||
@@ -327,6 +334,7 @@ export const createPublishGithubPullRequestAction = (
|
||||
head: branchName,
|
||||
draft,
|
||||
update,
|
||||
forceFork,
|
||||
};
|
||||
if (targetBranchName) {
|
||||
createOptions.base = targetBranchName;
|
||||
|
||||
@@ -270,6 +270,7 @@ export const createPublishGithubPullRequestAction: (
|
||||
teamReviewers?: string[] | undefined;
|
||||
commitMessage?: string | undefined;
|
||||
update?: boolean | undefined;
|
||||
forceFork?: boolean | undefined;
|
||||
},
|
||||
JsonObject
|
||||
>;
|
||||
|
||||
Reference in New Issue
Block a user