diff --git a/dist/150.index.js b/dist/150.index.js index 4516b9cb4..bffeb2f86 100644 --- a/dist/150.index.js +++ b/dist/150.index.js @@ -11,13 +11,11 @@ __webpack_require__.r(__webpack_exports__); /* harmony export */ "CreatePR": () => (/* binding */ CreatePR), /* harmony export */ "createPr": () => (/* binding */ createPr) /* harmony export */ }); -/* harmony import */ var _actions_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2186); -/* harmony import */ var _actions_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_actions_core__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var _types_generated__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(3476); -/* harmony import */ var _actions_github__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5438); -/* harmony import */ var _actions_github__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_actions_github__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var _octokit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6161); -/* harmony import */ var _utils_get_default_branch__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(977); +/* harmony import */ var _types_generated__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(3476); +/* harmony import */ var _actions_github__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5438); +/* harmony import */ var _actions_github__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_actions_github__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _octokit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6161); +/* harmony import */ var _utils_get_default_branch__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(977); /* Copyright 2021 Expedia, Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -43,23 +41,21 @@ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argume - -class CreatePR extends _types_generated__WEBPACK_IMPORTED_MODULE_4__/* .HelperInputs */ .s { +class CreatePR extends _types_generated__WEBPACK_IMPORTED_MODULE_3__/* .HelperInputs */ .s { constructor() { super(...arguments); this.title = ''; this.body = ''; } } -const createPr = ({ title, body, head = _actions_github__WEBPACK_IMPORTED_MODULE_1__.context.ref.replace('refs/heads/', ''), base }) => __awaiter(void 0, void 0, void 0, function* () { - const pr_base = base || (yield (0,_utils_get_default_branch__WEBPACK_IMPORTED_MODULE_3__/* .getDefaultBranch */ ._)()); +const createPr = ({ title, body, head = _actions_github__WEBPACK_IMPORTED_MODULE_0__.context.ref.replace('refs/heads/', ''), base, return_full_payload }) => __awaiter(void 0, void 0, void 0, function* () { + const pr_base = base || (yield (0,_utils_get_default_branch__WEBPACK_IMPORTED_MODULE_2__/* .getDefaultBranch */ ._)()); yield updateHeadWithBaseBranch(pr_base, head); - const { data } = yield _octokit__WEBPACK_IMPORTED_MODULE_2__/* .octokit.pulls.create */ .K.pulls.create(Object.assign({ title, - head, base: pr_base, body, maintainer_can_modify: true }, _actions_github__WEBPACK_IMPORTED_MODULE_1__.context.repo)); - const return_full_payload = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getBooleanInput('return_full_payload'); - return return_full_payload ? data : data.number; + const { data } = yield _octokit__WEBPACK_IMPORTED_MODULE_1__/* .octokit.pulls.create */ .K.pulls.create(Object.assign({ title, + head, base: pr_base, body, maintainer_can_modify: true }, _actions_github__WEBPACK_IMPORTED_MODULE_0__.context.repo)); + return return_full_payload === 'true' ? data : data.number; }); -const updateHeadWithBaseBranch = (base, head) => _octokit__WEBPACK_IMPORTED_MODULE_2__/* .octokit.repos.merge */ .K.repos.merge(Object.assign({ base: head, head: base }, _actions_github__WEBPACK_IMPORTED_MODULE_1__.context.repo)); +const updateHeadWithBaseBranch = (base, head) => _octokit__WEBPACK_IMPORTED_MODULE_1__/* .octokit.repos.merge */ .K.repos.merge(Object.assign({ base: head, head: base }, _actions_github__WEBPACK_IMPORTED_MODULE_0__.context.repo)); /***/ }), diff --git a/dist/150.index.js.map b/dist/150.index.js.map index d9ac6a50a..0714ddc55 100644 --- a/dist/150.index.js.map +++ b/dist/150.index.js.map @@ -1 +1 @@ -{"version":3,"file":"150.index.js","mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;AAWA;;;;;;;;;;AAEA;AACA;AACA;AACA;AACA;AAEA;AAAA;;AACA;AACA;AAIA;AAAA;AAEA;AACA;AACA;AACA;AAEA;AAMA;AACA;AACA;AAEA;;;;;;;;;;;;;;;;;;AC1CA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AAEA;AACA;;;;;;;;;;;AClBA;;;;;;;;;;;AAWA;AAEA;AA2CA;;;;;;;;;;;;;;ACxDA;;;;;;;;;;;AAWA;;;;;;;;;;AAEA;AACA;AAEA;AACA;AAGA;AACA","sources":["webpack://github-helpers/./src/helpers/create-pr.ts","webpack://github-helpers/./src/octokit.ts","webpack://github-helpers/./src/types/generated.ts","webpack://github-helpers/./src/utils/get-default-branch.ts"],"sourcesContent":["/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport * as core from '@actions/core';\nimport { HelperInputs } from '../types/generated';\nimport { context } from '@actions/github';\nimport { octokit } from '../octokit';\nimport { getDefaultBranch } from '../utils/get-default-branch';\n\nexport class CreatePR extends HelperInputs {\n title = '';\n body = '';\n head?: string;\n base?: string;\n return_full_payload?: string;\n}\n\nexport const createPr = async ({ title, body, head = context.ref.replace('refs/heads/', ''), base }: CreatePR) => {\n const pr_base = base || (await getDefaultBranch());\n await updateHeadWithBaseBranch(pr_base, head);\n const { data } = await octokit.pulls.create({\n title,\n head,\n base: pr_base,\n body,\n maintainer_can_modify: true,\n ...context.repo\n });\n const return_full_payload = core.getBooleanInput('return_full_payload');\n return return_full_payload ? data : data.number;\n};\n\nconst updateHeadWithBaseBranch = (base: string, head: string) =>\n octokit.repos.merge({\n base: head,\n head: base,\n ...context.repo\n });\n","/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport * as core from '@actions/core';\nimport * as fetch from '@adobe/node-fetch-retry';\nimport { getOctokit } from '@actions/github';\n\nconst githubToken = core.getInput('github_token', { required: true });\nexport const { rest: octokit, graphql: octokitGraphql } = getOctokit(githubToken, { request: { fetch } });\n","/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nexport class HelperInputs {\n helper?: string;\n github_token?: string;\n body?: string;\n project_name?: string;\n project_destination_column_name?: string;\n note?: string;\n project_origin_column_name?: string;\n sha?: string;\n context?: string;\n state?: string;\n description?: string;\n target_url?: string;\n environment?: string;\n environment_url?: string;\n label?: string;\n labels?: string;\n paths?: string;\n ignore_globs?: string;\n extensions?: string;\n override_filter_paths?: string;\n batches?: string;\n pattern?: string;\n teams?: string;\n login?: string;\n paths_no_filter?: string;\n slack_webhook_url?: string;\n number_of_assignees?: string;\n number_of_reviewers?: string;\n globs?: string;\n override_filter_globs?: string;\n title?: string;\n seconds?: string;\n pull_number?: string;\n base?: string;\n head?: string;\n days?: string;\n no_evict_upon_conflict?: string;\n skip_if_already_set?: string;\n delimiter?: string;\n team?: string;\n ignore_deleted?: string;\n return_full_payload?: string;\n}\n","/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { octokit } from '../octokit';\nimport { context } from '@actions/github';\n\nexport const getDefaultBranch = async () => {\n const {\n data: { default_branch }\n } = await octokit.repos.get({ ...context.repo });\n return default_branch;\n};\n"],"names":[],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"150.index.js","mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;AAWA;;;;;;;;;;AAEA;AACA;AACA;AACA;AAEA;AAAA;;AACA;AACA;AAIA;AAAA;AAEA;AACA;AACA;AACA;AAEA;AAMA;AACA;AAEA;;;;;;;;;;;;;;;;;;ACxCA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AAEA;AACA;;;;;;;;;;;AClBA;;;;;;;;;;;AAWA;AAEA;AA2CA;;;;;;;;;;;;;;ACxDA;;;;;;;;;;;AAWA;;;;;;;;;;AAEA;AACA;AAEA;AACA;AAGA;AACA","sources":["webpack://github-helpers/./src/helpers/create-pr.ts","webpack://github-helpers/./src/octokit.ts","webpack://github-helpers/./src/types/generated.ts","webpack://github-helpers/./src/utils/get-default-branch.ts"],"sourcesContent":["/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { HelperInputs } from '../types/generated';\nimport { context } from '@actions/github';\nimport { octokit } from '../octokit';\nimport { getDefaultBranch } from '../utils/get-default-branch';\n\nexport class CreatePR extends HelperInputs {\n title = '';\n body = '';\n head?: string;\n base?: string;\n return_full_payload?: string;\n}\n\nexport const createPr = async ({ title, body, head = context.ref.replace('refs/heads/', ''), base, return_full_payload }: CreatePR) => {\n const pr_base = base || (await getDefaultBranch());\n await updateHeadWithBaseBranch(pr_base, head);\n const { data } = await octokit.pulls.create({\n title,\n head,\n base: pr_base,\n body,\n maintainer_can_modify: true,\n ...context.repo\n });\n return return_full_payload === 'true' ? data : data.number;\n};\n\nconst updateHeadWithBaseBranch = (base: string, head: string) =>\n octokit.repos.merge({\n base: head,\n head: base,\n ...context.repo\n });\n","/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport * as core from '@actions/core';\nimport * as fetch from '@adobe/node-fetch-retry';\nimport { getOctokit } from '@actions/github';\n\nconst githubToken = core.getInput('github_token', { required: true });\nexport const { rest: octokit, graphql: octokitGraphql } = getOctokit(githubToken, { request: { fetch } });\n","/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nexport class HelperInputs {\n helper?: string;\n github_token?: string;\n body?: string;\n project_name?: string;\n project_destination_column_name?: string;\n note?: string;\n project_origin_column_name?: string;\n sha?: string;\n context?: string;\n state?: string;\n description?: string;\n target_url?: string;\n environment?: string;\n environment_url?: string;\n label?: string;\n labels?: string;\n paths?: string;\n ignore_globs?: string;\n extensions?: string;\n override_filter_paths?: string;\n batches?: string;\n pattern?: string;\n teams?: string;\n login?: string;\n paths_no_filter?: string;\n slack_webhook_url?: string;\n number_of_assignees?: string;\n number_of_reviewers?: string;\n globs?: string;\n override_filter_globs?: string;\n title?: string;\n seconds?: string;\n pull_number?: string;\n base?: string;\n head?: string;\n days?: string;\n no_evict_upon_conflict?: string;\n skip_if_already_set?: string;\n delimiter?: string;\n team?: string;\n ignore_deleted?: string;\n return_full_payload?: string;\n}\n","/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { octokit } from '../octokit';\nimport { context } from '@actions/github';\n\nexport const getDefaultBranch = async () => {\n const {\n data: { default_branch }\n } = await octokit.repos.get({ ...context.repo });\n return default_branch;\n};\n"],"names":[],"sourceRoot":""} \ No newline at end of file diff --git a/src/helpers/create-pr.ts b/src/helpers/create-pr.ts index c1c3e718e..9dddd1189 100644 --- a/src/helpers/create-pr.ts +++ b/src/helpers/create-pr.ts @@ -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'; @@ -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({ @@ -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) => diff --git a/test/helpers/create-pr.test.ts b/test/helpers/create-pr.test.ts index ba713fd65..c121665d4 100644 --- a/test/helpers/create-pr.test.ts +++ b/test/helpers/create-pr.test.ts @@ -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'; @@ -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,