Skip to content

Commit

Permalink
fix(create-pr): clean up return_full_payload input (#419)
Browse files Browse the repository at this point in the history
  • Loading branch information
danadajian authored Aug 30, 2023
1 parent 0439ac2 commit e579caa
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 23 deletions.
28 changes: 12 additions & 16 deletions dist/150.index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/150.index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions src/helpers/create-pr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import * as core from '@actions/core';
import { HelperInputs } from '../types/generated';
import { context } from '@actions/github';
import { octokit } from '../octokit';
Expand All @@ -25,7 +24,7 @@ export class CreatePR extends HelperInputs {
return_full_payload?: string;
}

export const createPr = async ({ title, body, head = context.ref.replace('refs/heads/', ''), base }: CreatePR) => {
export const createPr = async ({ title, body, head = context.ref.replace('refs/heads/', ''), base, return_full_payload }: CreatePR) => {
const pr_base = base || (await getDefaultBranch());
await updateHeadWithBaseBranch(pr_base, head);
const { data } = await octokit.pulls.create({
Expand All @@ -36,8 +35,7 @@ export const createPr = async ({ title, body, head = context.ref.replace('refs/h
maintainer_can_modify: true,
...context.repo
});
const return_full_payload = core.getBooleanInput('return_full_payload');
return return_full_payload ? data : data.number;
return return_full_payload === 'true' ? data : data.number;
};

const updateHeadWithBaseBranch = (base: string, head: string) =>
Expand Down
2 changes: 0 additions & 2 deletions test/helpers/create-pr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import * as core from '@actions/core';
import { Mocktokit } from '../types';
import { context } from '@actions/github';
import { createPr } from '../../src/helpers/create-pr';
Expand Down Expand Up @@ -90,7 +89,6 @@ describe('createPr', () => {
});

it('should return the full response object', async () => {
(core.getBooleanInput as jest.Mock).mockReturnValue(true);
const result = await createPr({
title,
body,
Expand Down

0 comments on commit e579caa

Please sign in to comment.