diff --git a/README.md b/README.md index 4b7bc7ed8..f0bc3296c 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Each of the following helpers are defined in a file of the same name in `src/hel * Adds one or more labels to a PR ### [**add-pr-approval-label**](.github/workflows/add-pr-approval-label.yml) * Upon PR review, adds a `CORE APPROVED` label if the reviewer is a part of the provided Github team, otherwise adds the `PEER APPROVED` label -### [**approve-pr**](.github/workflows/auto-approve-pr.yml) +### [**approve-pr**](.github/workflows/approve-pr.yml) * Approves a PR ### [**assign-pr-reviewers**](.github/workflows/assign-pr-reviewers.yml) * Randomly assigns members of a github team to review a PR. If `login` is provided, it does nothing if that user is already part of the team diff --git a/dist/169.index.js b/dist/169.index.js deleted file mode 100644 index 276c9035c..000000000 --- a/dist/169.index.js +++ /dev/null @@ -1,230 +0,0 @@ -exports.id = 169; -exports.ids = [169,939,61]; -exports.modules = { - -/***/ 9042: -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "Cc": () => (/* binding */ GITHUB_OPTIONS), -/* harmony export */ "$9": () => (/* binding */ DEFAULT_PIPELINE_STATUS), -/* harmony export */ "Km": () => (/* binding */ DEFAULT_PIPELINE_DESCRIPTION), -/* harmony export */ "Hc": () => (/* binding */ PRODUCTION_ENVIRONMENT), -/* harmony export */ "mj": () => (/* binding */ DEFAULT_BRANCH), -/* harmony export */ "_d": () => (/* binding */ CORE_APPROVED_PR_LABEL), -/* harmony export */ "Xt": () => (/* binding */ PEER_APPROVED_PR_LABEL), -/* harmony export */ "Ak": () => (/* binding */ READY_FOR_MERGE_PR_LABEL), -/* harmony export */ "Ee": () => (/* binding */ QUEUED_FOR_MERGE_PREFIX), -/* harmony export */ "IH": () => (/* binding */ FIRST_QUEUED_PR_LABEL), -/* harmony export */ "nJ": () => (/* binding */ JUMP_THE_QUEUE_PR_LABEL), -/* harmony export */ "HW": () => (/* binding */ DEFAULT_PR_TITLE_REGEX) -/* harmony export */ }); -/* unused harmony export DEFAULT_EXEMPT_DESCRIPTION */ -/* -Copyright 2021 Expedia, Inc. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - https://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -// These extra headers are for experimental operations. Newer versions of octokit may not require this -const GITHUB_OPTIONS = { - headers: { - accept: 'application/vnd.github.ant-man-preview+json,application/vnd.github.flash-preview+json,application/vnd.github.v3+json' - } -}; -const DEFAULT_EXEMPT_DESCRIPTION = 'Passed in case the check is exempt.'; -const DEFAULT_PIPELINE_STATUS = 'Pipeline Status'; -const DEFAULT_PIPELINE_DESCRIPTION = 'Pipeline clear.'; -const PRODUCTION_ENVIRONMENT = 'production'; -const DEFAULT_BRANCH = 'main'; -const CORE_APPROVED_PR_LABEL = 'CORE APPROVED'; -const PEER_APPROVED_PR_LABEL = 'PEER APPROVED'; -const READY_FOR_MERGE_PR_LABEL = 'READY FOR MERGE'; -const QUEUED_FOR_MERGE_PREFIX = 'QUEUED FOR MERGE'; -const FIRST_QUEUED_PR_LABEL = `${QUEUED_FOR_MERGE_PREFIX} #1`; -const JUMP_THE_QUEUE_PR_LABEL = 'JUMP THE QUEUE'; -const DEFAULT_PR_TITLE_REGEX = '^(build|ci|chore|docs|feat|fix|perf|refactor|style|test|revert|Revert|BREAKING CHANGE)((.*))?: .+$'; - - -/***/ }), - -/***/ 1939: -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "addLabels": () => (/* binding */ addLabels) -/* harmony export */ }); -/* 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); -/* -Copyright 2021 Expedia, Inc. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - https://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - - -const addLabels = ({ pull_number, labels }) => _octokit__WEBPACK_IMPORTED_MODULE_1__/* .octokit.issues.addLabels */ .K.issues.addLabels(Object.assign({ labels: labels.split('\n'), issue_number: Number(pull_number) }, _actions_github__WEBPACK_IMPORTED_MODULE_0__.context.repo)); - - -/***/ }), - -/***/ 61: -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "removeLabel": () => (/* binding */ removeLabel) -/* 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 _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); -/* -Copyright 2021 Expedia, Inc. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - https://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - - - -const removeLabel = ({ label, pull_number }) => _octokit__WEBPACK_IMPORTED_MODULE_2__/* .octokit.issues.removeLabel */ .K.issues.removeLabel(Object.assign({ name: label, issue_number: Number(pull_number) }, _actions_github__WEBPACK_IMPORTED_MODULE_1__.context.repo)) - .catch(error => { - if (error.status === 404) { - _actions_core__WEBPACK_IMPORTED_MODULE_0__.info('Label is not present on PR.'); - } -}); - - -/***/ }), - -/***/ 5169: -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "updateMergeQueue": () => (/* binding */ updateMergeQueue) -/* harmony export */ }); -/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9042); -/* harmony import */ var _add_labels__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1939); -/* harmony import */ var _utils_get_queued_pr_data__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4281); -/* harmony import */ var bluebird__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(8710); -/* harmony import */ var bluebird__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(bluebird__WEBPACK_IMPORTED_MODULE_3__); -/* harmony import */ var _remove_label__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(61); -var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; - - - - - -const updateMergeQueue = () => __awaiter(void 0, void 0, void 0, function* () { - const { data: { items } } = yield (0,_utils_get_queued_pr_data__WEBPACK_IMPORTED_MODULE_2__/* .getQueuedPrData */ .Z)(); - return (0,bluebird__WEBPACK_IMPORTED_MODULE_3__.map)(items, item => { - var _a; - const mergeLabel = (_a = item.labels.find(label => { var _a; return (_a = label.name) === null || _a === void 0 ? void 0 : _a.startsWith(_constants__WEBPACK_IMPORTED_MODULE_0__/* .QUEUED_FOR_MERGE_PREFIX */ .Ee); })) === null || _a === void 0 ? void 0 : _a.name; - if (!mergeLabel) { - return; - } - const pull_number = String(item.number); - const queueNumber = Number(mergeLabel.split('#')[1]); - return Promise.all([ - (0,_add_labels__WEBPACK_IMPORTED_MODULE_1__.addLabels)({ pull_number, labels: `${_constants__WEBPACK_IMPORTED_MODULE_0__/* .QUEUED_FOR_MERGE_PREFIX */ .Ee} #${queueNumber - 1}` }), - (0,_remove_label__WEBPACK_IMPORTED_MODULE_4__.removeLabel)({ pull_number, label: mergeLabel }) - ]); - }); -}); - - -/***/ }), - -/***/ 6161: -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "K": () => (/* binding */ octokit) -/* 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 _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__); -/* -Copyright 2021 Expedia, Inc. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - https://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - - -const octokit = (0,_actions_github__WEBPACK_IMPORTED_MODULE_1__.getOctokit)(_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput('github_token', { required: true })).rest; - - -/***/ }), - -/***/ 4281: -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "Z": () => (/* binding */ getQueuedPrData) -/* harmony export */ }); -/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9042); -/* 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); - - - -const getQueuedPrData = () => { - const { repo, owner } = _actions_github__WEBPACK_IMPORTED_MODULE_1__.context.repo; - return _octokit__WEBPACK_IMPORTED_MODULE_2__/* .octokit.search.issuesAndPullRequests */ .K.search.issuesAndPullRequests({ - q: encodeURIComponent(`org:${owner} repo:${repo} type:pr state:open label:"${_constants__WEBPACK_IMPORTED_MODULE_0__/* .QUEUED_FOR_MERGE_PREFIX */ .Ee}"`) - }); -}; - - -/***/ }) - -}; -; -//# sourceMappingURL=169.index.js.map \ No newline at end of file diff --git a/dist/169.index.js.map b/dist/169.index.js.map deleted file mode 100644 index 84f2677af..000000000 --- a/dist/169.index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"169.index.js","sources":["webpack://github-helpers/./src/constants.ts","webpack://github-helpers/./src/helpers/add-labels.ts","webpack://github-helpers/./src/helpers/remove-label.ts","webpack://github-helpers/./src/helpers/update-merge-queue.ts","webpack://github-helpers/./src/octokit.ts","webpack://github-helpers/./src/utils/get-queued-pr-data.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\n// These extra headers are for experimental operations. Newer versions of octokit may not require this\nexport const GITHUB_OPTIONS = {\n headers: {\n accept: 'application/vnd.github.ant-man-preview+json,application/vnd.github.flash-preview+json,application/vnd.github.v3+json'\n }\n};\n\nexport const DEFAULT_EXEMPT_DESCRIPTION = 'Passed in case the check is exempt.';\nexport const DEFAULT_PIPELINE_STATUS = 'Pipeline Status';\nexport const DEFAULT_PIPELINE_DESCRIPTION = 'Pipeline clear.';\nexport const PRODUCTION_ENVIRONMENT = 'production';\nexport const DEFAULT_BRANCH = 'main';\nexport const CORE_APPROVED_PR_LABEL = 'CORE APPROVED';\nexport const PEER_APPROVED_PR_LABEL = 'PEER APPROVED';\nexport const READY_FOR_MERGE_PR_LABEL = 'READY FOR MERGE';\nexport const QUEUED_FOR_MERGE_PREFIX = 'QUEUED FOR MERGE';\nexport const FIRST_QUEUED_PR_LABEL = `${QUEUED_FOR_MERGE_PREFIX} #1`;\nexport const JUMP_THE_QUEUE_PR_LABEL = 'JUMP THE QUEUE';\nexport const DEFAULT_PR_TITLE_REGEX = '^(build|ci|chore|docs|feat|fix|perf|refactor|style|test|revert|Revert|BREAKING CHANGE)((.*))?: .+$';\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 { context } from '@actions/github';\nimport { octokit } from '../octokit';\n\ninterface AddLabels {\n pull_number: string;\n labels: string;\n}\n\nexport const addLabels = ({ pull_number, labels }: AddLabels) =>\n octokit.issues.addLabels({\n labels: labels.split('\\n'),\n issue_number: Number(pull_number),\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 { context } from '@actions/github';\nimport { octokit } from '../octokit';\n\ninterface RemoveLabel {\n label: string;\n pull_number: string;\n}\n\nexport const removeLabel = ({ label, pull_number }: RemoveLabel) =>\n octokit.issues\n .removeLabel({\n name: label,\n issue_number: Number(pull_number),\n ...context.repo\n })\n .catch(error => {\n if (error.status === 404) {\n core.info('Label is not present on PR.');\n }\n });\n","import { QUEUED_FOR_MERGE_PREFIX } from '../constants';\nimport { addLabels } from './add-labels';\nimport { getQueuedPrData } from '../utils/get-queued-pr-data';\nimport { map } from 'bluebird';\nimport { removeLabel } from './remove-label';\n\nexport const updateMergeQueue = async () => {\n const {\n data: { items }\n } = await getQueuedPrData();\n return map(items, item => {\n const mergeLabel = item.labels.find(label => label.name?.startsWith(QUEUED_FOR_MERGE_PREFIX))?.name;\n if (!mergeLabel) {\n return;\n }\n const pull_number = String(item.number);\n const queueNumber = Number(mergeLabel.split('#')[1]);\n return Promise.all([\n addLabels({ pull_number, labels: `${QUEUED_FOR_MERGE_PREFIX} #${queueNumber - 1}` }),\n removeLabel({ pull_number, label: mergeLabel })\n ]);\n });\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 { Octokit } from '@octokit/rest';\nimport { getOctokit } from '@actions/github';\n\nexport const octokit = getOctokit(core.getInput('github_token', { required: true })).rest as unknown as Octokit;\n","import { QUEUED_FOR_MERGE_PREFIX } from '../constants';\nimport { context } from '@actions/github';\nimport { octokit } from '../octokit';\n\nexport const getQueuedPrData = () => {\n const { repo, owner } = context.repo;\n return octokit.search.issuesAndPullRequests({\n q: encodeURIComponent(`org:${owner} repo:${repo} type:pr state:open label:\"${QUEUED_FOR_MERGE_PREFIX}\"`)\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;;;;;;;;AC/BA;;;;;;;;;;;AAWA;AAEA;AACA;AAOA;;;A;;;;;;;;;;;;;;;ACrBA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AAOA,4IAEA;AAKA;AACA;AACA;AACA;AACA;;;A;;;;;;;;;;;;;;;;;;;;;;;;;ACjCA;AACA;AACA;AACA;AACA;AAEA;AACA;AAGA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;;;;;;;;ACtBA;;;;;;;;;;;AAWA;AAEA;AAEA;AAEA;;;A;;;;;;;;;;;;;ACjBA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;;;A;;;A","sourceRoot":""} \ No newline at end of file diff --git a/dist/185.index.js b/dist/185.index.js deleted file mode 100644 index fa46051ab..000000000 --- a/dist/185.index.js +++ /dev/null @@ -1,71 +0,0 @@ -exports.id = 185; -exports.ids = [185]; -exports.modules = { - -/***/ 185: -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "autoApprovePr": () => (/* binding */ autoApprovePr) -/* harmony export */ }); -/* 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); -/* -Copyright 2021 Expedia, Inc. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - https://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - - -const autoApprovePr = ({ login, auto_approved_user }) => { - if (login === auto_approved_user) { - _octokit__WEBPACK_IMPORTED_MODULE_1__/* .octokit.pulls.createReview */ .K.pulls.createReview(Object.assign(Object.assign({}, _actions_github__WEBPACK_IMPORTED_MODULE_0__.context.repo), { pull_number: _actions_github__WEBPACK_IMPORTED_MODULE_0__.context.issue.number, body: 'Approved by bot', event: 'APPROVE' })); - } -}; - - -/***/ }), - -/***/ 6161: -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "K": () => (/* binding */ octokit) -/* 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 _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__); -/* -Copyright 2021 Expedia, Inc. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - https://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - - -const octokit = (0,_actions_github__WEBPACK_IMPORTED_MODULE_1__.getOctokit)(_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput('github_token', { required: true })).rest; - - -/***/ }) - -}; -; -//# sourceMappingURL=185.index.js.map \ No newline at end of file diff --git a/dist/185.index.js.map b/dist/185.index.js.map deleted file mode 100644 index 3a7b1f8c8..000000000 --- a/dist/185.index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"185.index.js","sources":["webpack://github-helpers/./src/helpers/auto-approve-pr.ts","webpack://github-helpers/./src/octokit.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 { context } from '@actions/github';\nimport { octokit } from '../octokit';\n\ninterface AutoApprovePr {\n login: string;\n auto_approved_user: string;\n}\n\nexport const autoApprovePr = ({ login, auto_approved_user }: AutoApprovePr) => {\n if (login === auto_approved_user) {\n octokit.pulls.createReview({\n ...context.repo,\n pull_number: context.issue.number,\n body: 'Approved by bot',\n event: 'APPROVE'\n });\n }\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 { Octokit } from '@octokit/rest';\nimport { getOctokit } from '@actions/github';\n\nexport const octokit = getOctokit(core.getInput('github_token', { required: true })).rest as unknown as Octokit;\n"],"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;;AAWA;AAEA;AACA;AAOA;AACA;AACA;AAMA;AACA;;;A;;;;;;;;;;;;;AC9BA;;;;;;;;;;;AAWA;AAEA;AAEA;AAEA;;;A;;;A","sourceRoot":""} \ No newline at end of file diff --git a/dist/597.index.js b/dist/597.index.js deleted file mode 100644 index 289762c7c..000000000 --- a/dist/597.index.js +++ /dev/null @@ -1,249 +0,0 @@ -exports.id = 597; -exports.ids = [597,61,209]; -exports.modules = { - -/***/ 9042: -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "Cc": () => (/* binding */ GITHUB_OPTIONS), -/* harmony export */ "$9": () => (/* binding */ DEFAULT_PIPELINE_STATUS), -/* harmony export */ "Km": () => (/* binding */ DEFAULT_PIPELINE_DESCRIPTION), -/* harmony export */ "Hc": () => (/* binding */ PRODUCTION_ENVIRONMENT), -/* harmony export */ "mj": () => (/* binding */ DEFAULT_BRANCH), -/* harmony export */ "_d": () => (/* binding */ CORE_APPROVED_PR_LABEL), -/* harmony export */ "Xt": () => (/* binding */ PEER_APPROVED_PR_LABEL), -/* harmony export */ "Ak": () => (/* binding */ READY_FOR_MERGE_PR_LABEL), -/* harmony export */ "Ee": () => (/* binding */ QUEUED_FOR_MERGE_PREFIX), -/* harmony export */ "IH": () => (/* binding */ FIRST_QUEUED_PR_LABEL), -/* harmony export */ "nJ": () => (/* binding */ JUMP_THE_QUEUE_PR_LABEL), -/* harmony export */ "HW": () => (/* binding */ DEFAULT_PR_TITLE_REGEX) -/* harmony export */ }); -/* unused harmony export DEFAULT_EXEMPT_DESCRIPTION */ -/* -Copyright 2021 Expedia, Inc. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - https://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -// These extra headers are for experimental operations. Newer versions of octokit may not require this -const GITHUB_OPTIONS = { - headers: { - accept: 'application/vnd.github.ant-man-preview+json,application/vnd.github.flash-preview+json,application/vnd.github.v3+json' - } -}; -const DEFAULT_EXEMPT_DESCRIPTION = 'Passed in case the check is exempt.'; -const DEFAULT_PIPELINE_STATUS = 'Pipeline Status'; -const DEFAULT_PIPELINE_DESCRIPTION = 'Pipeline clear.'; -const PRODUCTION_ENVIRONMENT = 'production'; -const DEFAULT_BRANCH = 'main'; -const CORE_APPROVED_PR_LABEL = 'CORE APPROVED'; -const PEER_APPROVED_PR_LABEL = 'PEER APPROVED'; -const READY_FOR_MERGE_PR_LABEL = 'READY FOR MERGE'; -const QUEUED_FOR_MERGE_PREFIX = 'QUEUED FOR MERGE'; -const FIRST_QUEUED_PR_LABEL = `${QUEUED_FOR_MERGE_PREFIX} #1`; -const JUMP_THE_QUEUE_PR_LABEL = 'JUMP THE QUEUE'; -const DEFAULT_PR_TITLE_REGEX = '^(build|ci|chore|docs|feat|fix|perf|refactor|style|test|revert|Revert|BREAKING CHANGE)((.*))?: .+$'; - - -/***/ }), - -/***/ 9597: -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "addPrToMergeQueue": () => (/* binding */ addPrToMergeQueue) -/* 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 _constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9042); -/* harmony import */ var _actions_github__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5438); -/* harmony import */ var _actions_github__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_actions_github__WEBPACK_IMPORTED_MODULE_2__); -/* harmony import */ var _utils_get_queued_pr_data__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(4281); -/* harmony import */ var _octokit__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(6161); -/* harmony import */ var _remove_label__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(61); -/* harmony import */ var _set_commit_status__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(2209); -var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; - - - - - - - -const addPrToMergeQueue = ({ sha }) => __awaiter(void 0, void 0, void 0, function* () { - var _a; - const issue_number = _actions_github__WEBPACK_IMPORTED_MODULE_2__.context.issue.number; - const { data } = yield _octokit__WEBPACK_IMPORTED_MODULE_4__/* .octokit.issues.listLabelsOnIssue */ .K.issues.listLabelsOnIssue(Object.assign({ issue_number }, _actions_github__WEBPACK_IMPORTED_MODULE_2__.context.repo)); - if (!data.find(label => label.name === _constants__WEBPACK_IMPORTED_MODULE_1__/* .READY_FOR_MERGE_PR_LABEL */ .Ak)) { - _actions_core__WEBPACK_IMPORTED_MODULE_0__.info('PR is not ready for merge.'); - const queueLabel = (_a = data.find(label => label.name.startsWith(_constants__WEBPACK_IMPORTED_MODULE_1__/* .QUEUED_FOR_MERGE_PREFIX */ .Ee))) === null || _a === void 0 ? void 0 : _a.name; - if (queueLabel) { - yield (0,_remove_label__WEBPACK_IMPORTED_MODULE_5__.removeLabel)({ label: queueLabel, pull_number: String(issue_number) }); - } - return; - } - const { data: { total_count } } = yield (0,_utils_get_queued_pr_data__WEBPACK_IMPORTED_MODULE_3__/* .getQueuedPrData */ .Z)(); - const numberInQueue = total_count + 1; - if (numberInQueue === 1 || data.find(label => label.name === _constants__WEBPACK_IMPORTED_MODULE_1__/* .FIRST_QUEUED_PR_LABEL */ .IH)) { - yield (0,_set_commit_status__WEBPACK_IMPORTED_MODULE_6__.setCommitStatus)({ - sha, - context: 'QUEUE CHECKER', - state: 'success' - }); - } - return _octokit__WEBPACK_IMPORTED_MODULE_4__/* .octokit.issues.addLabels */ .K.issues.addLabels(Object.assign({ labels: [`${_constants__WEBPACK_IMPORTED_MODULE_1__/* .QUEUED_FOR_MERGE_PREFIX */ .Ee} #${numberInQueue}`], issue_number }, _actions_github__WEBPACK_IMPORTED_MODULE_2__.context.repo)); -}); - - -/***/ }), - -/***/ 61: -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "removeLabel": () => (/* binding */ removeLabel) -/* 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 _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); -/* -Copyright 2021 Expedia, Inc. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - https://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - - - -const removeLabel = ({ label, pull_number }) => _octokit__WEBPACK_IMPORTED_MODULE_2__/* .octokit.issues.removeLabel */ .K.issues.removeLabel(Object.assign({ name: label, issue_number: Number(pull_number) }, _actions_github__WEBPACK_IMPORTED_MODULE_1__.context.repo)) - .catch(error => { - if (error.status === 404) { - _actions_core__WEBPACK_IMPORTED_MODULE_0__.info('Label is not present on PR.'); - } -}); - - -/***/ }), - -/***/ 2209: -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "setCommitStatus": () => (/* binding */ setCommitStatus) -/* harmony export */ }); -/* 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 bluebird__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8710); -/* harmony import */ var bluebird__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(bluebird__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var _octokit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6161); -/* -Copyright 2021 Expedia, Inc. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - https://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - - - -const setCommitStatus = ({ sha, context, state, description, target_url }) => (0,bluebird__WEBPACK_IMPORTED_MODULE_1__.map)(context.split('\n'), context => _octokit__WEBPACK_IMPORTED_MODULE_2__/* .octokit.repos.createCommitStatus */ .K.repos.createCommitStatus(Object.assign({ sha, - context, - state, - description, - target_url }, _actions_github__WEBPACK_IMPORTED_MODULE_0__.context.repo))); - - -/***/ }), - -/***/ 6161: -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "K": () => (/* binding */ octokit) -/* 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 _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__); -/* -Copyright 2021 Expedia, Inc. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - https://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - - -const octokit = (0,_actions_github__WEBPACK_IMPORTED_MODULE_1__.getOctokit)(_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput('github_token', { required: true })).rest; - - -/***/ }), - -/***/ 4281: -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "Z": () => (/* binding */ getQueuedPrData) -/* harmony export */ }); -/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9042); -/* 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); - - - -const getQueuedPrData = () => { - const { repo, owner } = _actions_github__WEBPACK_IMPORTED_MODULE_1__.context.repo; - return _octokit__WEBPACK_IMPORTED_MODULE_2__/* .octokit.search.issuesAndPullRequests */ .K.search.issuesAndPullRequests({ - q: encodeURIComponent(`org:${owner} repo:${repo} type:pr state:open label:"${_constants__WEBPACK_IMPORTED_MODULE_0__/* .QUEUED_FOR_MERGE_PREFIX */ .Ee}"`) - }); -}; - - -/***/ }) - -}; -; -//# sourceMappingURL=597.index.js.map \ No newline at end of file diff --git a/dist/597.index.js.map b/dist/597.index.js.map deleted file mode 100644 index 449c89047..000000000 --- a/dist/597.index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"597.index.js","sources":["webpack://github-helpers/./src/constants.ts","webpack://github-helpers/./src/helpers/add-pr-to-merge-queue.ts","webpack://github-helpers/./src/helpers/remove-label.ts","webpack://github-helpers/./src/helpers/set-commit-status.ts","webpack://github-helpers/./src/octokit.ts","webpack://github-helpers/./src/utils/get-queued-pr-data.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\n// These extra headers are for experimental operations. Newer versions of octokit may not require this\nexport const GITHUB_OPTIONS = {\n headers: {\n accept: 'application/vnd.github.ant-man-preview+json,application/vnd.github.flash-preview+json,application/vnd.github.v3+json'\n }\n};\n\nexport const DEFAULT_EXEMPT_DESCRIPTION = 'Passed in case the check is exempt.';\nexport const DEFAULT_PIPELINE_STATUS = 'Pipeline Status';\nexport const DEFAULT_PIPELINE_DESCRIPTION = 'Pipeline clear.';\nexport const PRODUCTION_ENVIRONMENT = 'production';\nexport const DEFAULT_BRANCH = 'main';\nexport const CORE_APPROVED_PR_LABEL = 'CORE APPROVED';\nexport const PEER_APPROVED_PR_LABEL = 'PEER APPROVED';\nexport const READY_FOR_MERGE_PR_LABEL = 'READY FOR MERGE';\nexport const QUEUED_FOR_MERGE_PREFIX = 'QUEUED FOR MERGE';\nexport const FIRST_QUEUED_PR_LABEL = `${QUEUED_FOR_MERGE_PREFIX} #1`;\nexport const JUMP_THE_QUEUE_PR_LABEL = 'JUMP THE QUEUE';\nexport const DEFAULT_PR_TITLE_REGEX = '^(build|ci|chore|docs|feat|fix|perf|refactor|style|test|revert|Revert|BREAKING CHANGE)((.*))?: .+$';\n","import * as core from '@actions/core';\nimport { FIRST_QUEUED_PR_LABEL, QUEUED_FOR_MERGE_PREFIX, READY_FOR_MERGE_PR_LABEL } from '../constants';\nimport { context } from '@actions/github';\nimport { getQueuedPrData } from '../utils/get-queued-pr-data';\nimport { octokit } from '../octokit';\nimport { removeLabel } from './remove-label';\nimport { setCommitStatus } from './set-commit-status';\n\ninterface AddPrToMergeQueue {\n sha: string;\n}\n\nexport const addPrToMergeQueue = async ({ sha }: AddPrToMergeQueue) => {\n const issue_number = context.issue.number;\n const { data } = await octokit.issues.listLabelsOnIssue({\n issue_number,\n ...context.repo\n });\n if (!data.find(label => label.name === READY_FOR_MERGE_PR_LABEL)) {\n core.info('PR is not ready for merge.');\n const queueLabel = data.find(label => label.name.startsWith(QUEUED_FOR_MERGE_PREFIX))?.name;\n if (queueLabel) {\n await removeLabel({ label: queueLabel, pull_number: String(issue_number) });\n }\n return;\n }\n const {\n data: { total_count }\n } = await getQueuedPrData();\n const numberInQueue = total_count + 1;\n if (numberInQueue === 1 || data.find(label => label.name === FIRST_QUEUED_PR_LABEL)) {\n await setCommitStatus({\n sha,\n context: 'QUEUE CHECKER',\n state: 'success'\n });\n }\n return octokit.issues.addLabels({\n labels: [`${QUEUED_FOR_MERGE_PREFIX} #${numberInQueue}`],\n issue_number,\n ...context.repo\n });\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 { context } from '@actions/github';\nimport { octokit } from '../octokit';\n\ninterface RemoveLabel {\n label: string;\n pull_number: string;\n}\n\nexport const removeLabel = ({ label, pull_number }: RemoveLabel) =>\n octokit.issues\n .removeLabel({\n name: label,\n issue_number: Number(pull_number),\n ...context.repo\n })\n .catch(error => {\n if (error.status === 404) {\n core.info('Label is not present on PR.');\n }\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 { PipelineState } from '../types';\nimport { context as githubContext } from '@actions/github';\nimport { map } from 'bluebird';\nimport { octokit } from '../octokit';\n\ninterface SetCommitStatus {\n sha: string;\n context: string;\n state: PipelineState;\n description?: string;\n target_url?: string;\n}\n\nexport const setCommitStatus = ({ sha, context, state, description, target_url }: SetCommitStatus) =>\n map(context.split('\\n'), context =>\n octokit.repos.createCommitStatus({\n sha,\n context,\n state,\n description,\n target_url,\n ...githubContext.repo\n })\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 { Octokit } from '@octokit/rest';\nimport { getOctokit } from '@actions/github';\n\nexport const octokit = getOctokit(core.getInput('github_token', { required: true })).rest as unknown as Octokit;\n","import { QUEUED_FOR_MERGE_PREFIX } from '../constants';\nimport { context } from '@actions/github';\nimport { octokit } from '../octokit';\n\nexport const getQueuedPrData = () => {\n const { repo, owner } = context.repo;\n return octokit.search.issuesAndPullRequests({\n q: encodeURIComponent(`org:${owner} repo:${repo} type:pr state:open label:\"${QUEUED_FOR_MERGE_PREFIX}\"`)\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC/BA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;;;A;;;;;;;;;;;;;;;AC1CA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AAOA,4IAEA;AAKA;AACA;AACA;AACA;AACA;;;A;;;;;;;;;;;;;;;ACjCA;;;;;;;;;;;AAWA;AAGA;AACA;AACA;AAUA;AAIA;AACA;AACA;AACA;;;A;;;;;;;;;;;;;ACjCA;;;;;;;;;;;AAWA;AAEA;AAEA;AAEA;;;A;;;;;;;;;;;;;ACjBA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;;;A;;;A","sourceRoot":""} \ No newline at end of file diff --git a/dist/733.index.js b/dist/733.index.js deleted file mode 100644 index 21bd13d91..000000000 --- a/dist/733.index.js +++ /dev/null @@ -1,311 +0,0 @@ -exports.id = 733; -exports.ids = [733,939,61,209]; -exports.modules = { - -/***/ 9042: -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "Cc": () => (/* binding */ GITHUB_OPTIONS), -/* harmony export */ "$9": () => (/* binding */ DEFAULT_PIPELINE_STATUS), -/* harmony export */ "Km": () => (/* binding */ DEFAULT_PIPELINE_DESCRIPTION), -/* harmony export */ "Hc": () => (/* binding */ PRODUCTION_ENVIRONMENT), -/* harmony export */ "mj": () => (/* binding */ DEFAULT_BRANCH), -/* harmony export */ "_d": () => (/* binding */ CORE_APPROVED_PR_LABEL), -/* harmony export */ "Xt": () => (/* binding */ PEER_APPROVED_PR_LABEL), -/* harmony export */ "Ak": () => (/* binding */ READY_FOR_MERGE_PR_LABEL), -/* harmony export */ "Ee": () => (/* binding */ QUEUED_FOR_MERGE_PREFIX), -/* harmony export */ "IH": () => (/* binding */ FIRST_QUEUED_PR_LABEL), -/* harmony export */ "nJ": () => (/* binding */ JUMP_THE_QUEUE_PR_LABEL), -/* harmony export */ "HW": () => (/* binding */ DEFAULT_PR_TITLE_REGEX) -/* harmony export */ }); -/* unused harmony export DEFAULT_EXEMPT_DESCRIPTION */ -/* -Copyright 2021 Expedia, Inc. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - https://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -// These extra headers are for experimental operations. Newer versions of octokit may not require this -const GITHUB_OPTIONS = { - headers: { - accept: 'application/vnd.github.ant-man-preview+json,application/vnd.github.flash-preview+json,application/vnd.github.v3+json' - } -}; -const DEFAULT_EXEMPT_DESCRIPTION = 'Passed in case the check is exempt.'; -const DEFAULT_PIPELINE_STATUS = 'Pipeline Status'; -const DEFAULT_PIPELINE_DESCRIPTION = 'Pipeline clear.'; -const PRODUCTION_ENVIRONMENT = 'production'; -const DEFAULT_BRANCH = 'main'; -const CORE_APPROVED_PR_LABEL = 'CORE APPROVED'; -const PEER_APPROVED_PR_LABEL = 'PEER APPROVED'; -const READY_FOR_MERGE_PR_LABEL = 'READY FOR MERGE'; -const QUEUED_FOR_MERGE_PREFIX = 'QUEUED FOR MERGE'; -const FIRST_QUEUED_PR_LABEL = `${QUEUED_FOR_MERGE_PREFIX} #1`; -const JUMP_THE_QUEUE_PR_LABEL = 'JUMP THE QUEUE'; -const DEFAULT_PR_TITLE_REGEX = '^(build|ci|chore|docs|feat|fix|perf|refactor|style|test|revert|Revert|BREAKING CHANGE)((.*))?: .+$'; - - -/***/ }), - -/***/ 1939: -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "addLabels": () => (/* binding */ addLabels) -/* harmony export */ }); -/* 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); -/* -Copyright 2021 Expedia, Inc. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - https://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - - -const addLabels = ({ pull_number, labels }) => _octokit__WEBPACK_IMPORTED_MODULE_1__/* .octokit.issues.addLabels */ .K.issues.addLabels(Object.assign({ labels: labels.split('\n'), issue_number: Number(pull_number) }, _actions_github__WEBPACK_IMPORTED_MODULE_0__.context.repo)); - - -/***/ }), - -/***/ 1733: -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -// ESM COMPAT FLAG -__webpack_require__.r(__webpack_exports__); - -// EXPORTS -__webpack_require__.d(__webpack_exports__, { - "manageMergeQueue": () => (/* binding */ manageMergeQueue) -}); - -// EXTERNAL MODULE: ./node_modules/@actions/core/lib/core.js -var core = __webpack_require__(2186); -// EXTERNAL MODULE: ./src/constants.ts -var constants = __webpack_require__(9042); -// EXTERNAL MODULE: ./src/helpers/add-labels.ts -var add_labels = __webpack_require__(1939); -// EXTERNAL MODULE: ./node_modules/@actions/github/lib/github.js -var github = __webpack_require__(5438); -// EXTERNAL MODULE: ./src/octokit.ts -var octokit = __webpack_require__(6161); -;// CONCATENATED MODULE: ./src/utils/get-queued-pr-data.ts - - - -const getQueuedPrData = () => { - const { repo, owner } = github.context.repo; - return octokit/* octokit.search.issuesAndPullRequests */.K.search.issuesAndPullRequests({ - q: encodeURIComponent(`org:${owner} repo:${repo} type:pr state:open label:"${constants/* QUEUED_FOR_MERGE_PREFIX */.Ee}"`) - }); -}; - -// EXTERNAL MODULE: ./node_modules/bluebird/js/release/bluebird.js -var bluebird = __webpack_require__(8710); -// EXTERNAL MODULE: ./src/helpers/remove-label.ts -var remove_label = __webpack_require__(61); -// EXTERNAL MODULE: ./src/helpers/set-commit-status.ts -var set_commit_status = __webpack_require__(2209); -;// CONCATENATED MODULE: ./src/helpers/manage-merge-queue.ts -/* -Copyright 2021 Expedia, Inc. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - https://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; - - - - - - - - - -const manageMergeQueue = ({ sha }) => __awaiter(void 0, void 0, void 0, function* () { - var _a; - const { data: { items, total_count } } = yield getQueuedPrData(); - const issue_number = github.context.issue.number; - if (!issue_number) { - return updateMergeQueue(items); - } - const { data } = yield octokit/* octokit.issues.listLabelsOnIssue */.K.issues.listLabelsOnIssue(Object.assign({ issue_number }, github.context.repo)); - if (!data.find(label => label.name === constants/* READY_FOR_MERGE_PR_LABEL */.Ak)) { - core.info('PR is not ready for merge.'); - const queueLabel = (_a = data.find(label => label.name.startsWith(constants/* QUEUED_FOR_MERGE_PREFIX */.Ee))) === null || _a === void 0 ? void 0 : _a.name; - if (queueLabel) { - yield (0,remove_label.removeLabel)({ label: queueLabel, pull_number: String(issue_number) }); - yield updateMergeQueue(items); - } - return; - } - const numberInQueue = total_count + 1; - if (numberInQueue === 1 || data.find(label => label.name === constants/* FIRST_QUEUED_PR_LABEL */.IH)) { - yield (0,set_commit_status.setCommitStatus)({ - sha, - context: 'QUEUE CHECKER', - state: 'success' - }); - } - return octokit/* octokit.issues.addLabels */.K.issues.addLabels(Object.assign({ labels: [`${constants/* QUEUED_FOR_MERGE_PREFIX */.Ee} #${numberInQueue}`], issue_number }, github.context.repo)); -}); -const updateMergeQueue = (queuedPrs) => __awaiter(void 0, void 0, void 0, function* () { - return (0,bluebird.map)(queuedPrs, pr => { - var _a; - const mergeLabel = (_a = pr.labels.find(label => { var _a; return (_a = label.name) === null || _a === void 0 ? void 0 : _a.startsWith(constants/* QUEUED_FOR_MERGE_PREFIX */.Ee); })) === null || _a === void 0 ? void 0 : _a.name; - if (!mergeLabel) { - return; - } - const pull_number = String(pr.number); - const queueNumber = Number(mergeLabel.split('#')[1]); - return Promise.all([ - (0,add_labels.addLabels)({ pull_number, labels: `${constants/* QUEUED_FOR_MERGE_PREFIX */.Ee} #${queueNumber - 1}` }), - (0,remove_label.removeLabel)({ pull_number, label: mergeLabel }) - ]); - }); -}); - - -/***/ }), - -/***/ 61: -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "removeLabel": () => (/* binding */ removeLabel) -/* 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 _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); -/* -Copyright 2021 Expedia, Inc. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - https://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - - - -const removeLabel = ({ label, pull_number }) => _octokit__WEBPACK_IMPORTED_MODULE_2__/* .octokit.issues.removeLabel */ .K.issues.removeLabel(Object.assign({ name: label, issue_number: Number(pull_number) }, _actions_github__WEBPACK_IMPORTED_MODULE_1__.context.repo)) - .catch(error => { - if (error.status === 404) { - _actions_core__WEBPACK_IMPORTED_MODULE_0__.info('Label is not present on PR.'); - } -}); - - -/***/ }), - -/***/ 2209: -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "setCommitStatus": () => (/* binding */ setCommitStatus) -/* harmony export */ }); -/* 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 bluebird__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8710); -/* harmony import */ var bluebird__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(bluebird__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var _octokit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6161); -/* -Copyright 2021 Expedia, Inc. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - https://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - - - -const setCommitStatus = ({ sha, context, state, description, target_url }) => (0,bluebird__WEBPACK_IMPORTED_MODULE_1__.map)(context.split('\n'), context => _octokit__WEBPACK_IMPORTED_MODULE_2__/* .octokit.repos.createCommitStatus */ .K.repos.createCommitStatus(Object.assign({ sha, - context, - state, - description, - target_url }, _actions_github__WEBPACK_IMPORTED_MODULE_0__.context.repo))); - - -/***/ }), - -/***/ 6161: -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "K": () => (/* binding */ octokit) -/* 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 _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__); -/* -Copyright 2021 Expedia, Inc. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - https://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - - -const octokit = (0,_actions_github__WEBPACK_IMPORTED_MODULE_1__.getOctokit)(_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput('github_token', { required: true })).rest; - - -/***/ }) - -}; -; -//# sourceMappingURL=733.index.js.map \ No newline at end of file diff --git a/dist/733.index.js.map b/dist/733.index.js.map deleted file mode 100644 index 2d0c6a86d..000000000 --- a/dist/733.index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"733.index.js","sources":["webpack://github-helpers/./src/constants.ts","webpack://github-helpers/./src/helpers/add-labels.ts","webpack://github-helpers/./src/utils/get-queued-pr-data.ts","webpack://github-helpers/./src/helpers/manage-merge-queue.ts","webpack://github-helpers/./src/helpers/remove-label.ts","webpack://github-helpers/./src/helpers/set-commit-status.ts","webpack://github-helpers/./src/octokit.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\n// These extra headers are for experimental operations. Newer versions of octokit may not require this\nexport const GITHUB_OPTIONS = {\n headers: {\n accept: 'application/vnd.github.ant-man-preview+json,application/vnd.github.flash-preview+json,application/vnd.github.v3+json'\n }\n};\n\nexport const DEFAULT_EXEMPT_DESCRIPTION = 'Passed in case the check is exempt.';\nexport const DEFAULT_PIPELINE_STATUS = 'Pipeline Status';\nexport const DEFAULT_PIPELINE_DESCRIPTION = 'Pipeline clear.';\nexport const PRODUCTION_ENVIRONMENT = 'production';\nexport const DEFAULT_BRANCH = 'main';\nexport const CORE_APPROVED_PR_LABEL = 'CORE APPROVED';\nexport const PEER_APPROVED_PR_LABEL = 'PEER APPROVED';\nexport const READY_FOR_MERGE_PR_LABEL = 'READY FOR MERGE';\nexport const QUEUED_FOR_MERGE_PREFIX = 'QUEUED FOR MERGE';\nexport const FIRST_QUEUED_PR_LABEL = `${QUEUED_FOR_MERGE_PREFIX} #1`;\nexport const JUMP_THE_QUEUE_PR_LABEL = 'JUMP THE QUEUE';\nexport const DEFAULT_PR_TITLE_REGEX = '^(build|ci|chore|docs|feat|fix|perf|refactor|style|test|revert|Revert|BREAKING CHANGE)((.*))?: .+$';\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 { context } from '@actions/github';\nimport { octokit } from '../octokit';\n\ninterface AddLabels {\n pull_number: string;\n labels: string;\n}\n\nexport const addLabels = ({ pull_number, labels }: AddLabels) =>\n octokit.issues.addLabels({\n labels: labels.split('\\n'),\n issue_number: Number(pull_number),\n ...context.repo\n });\n","import { QUEUED_FOR_MERGE_PREFIX } from '../constants';\nimport { context } from '@actions/github';\nimport { octokit } from '../octokit';\n\nexport const getQueuedPrData = () => {\n const { repo, owner } = context.repo;\n return octokit.search.issuesAndPullRequests({\n q: encodeURIComponent(`org:${owner} repo:${repo} type:pr state:open label:\"${QUEUED_FOR_MERGE_PREFIX}\"`)\n });\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 { FIRST_QUEUED_PR_LABEL, QUEUED_FOR_MERGE_PREFIX, READY_FOR_MERGE_PR_LABEL } from '../constants';\nimport { IssuesAndPullRequestsResponse } from '../types';\nimport { addLabels } from './add-labels';\nimport { context } from '@actions/github';\nimport { getQueuedPrData } from '../utils/get-queued-pr-data';\nimport { map } from 'bluebird';\nimport { octokit } from '../octokit';\nimport { removeLabel } from './remove-label';\nimport { setCommitStatus } from './set-commit-status';\n\ninterface ManageMergeQueue {\n sha: string;\n}\n\nexport const manageMergeQueue = async ({ sha }: ManageMergeQueue) => {\n const {\n data: { items, total_count }\n } = await getQueuedPrData();\n const issue_number = context.issue.number;\n if (!issue_number) {\n return updateMergeQueue(items);\n }\n\n const { data } = await octokit.issues.listLabelsOnIssue({\n issue_number,\n ...context.repo\n });\n if (!data.find(label => label.name === READY_FOR_MERGE_PR_LABEL)) {\n core.info('PR is not ready for merge.');\n const queueLabel = data.find(label => label.name.startsWith(QUEUED_FOR_MERGE_PREFIX))?.name;\n if (queueLabel) {\n await removeLabel({ label: queueLabel, pull_number: String(issue_number) });\n await updateMergeQueue(items);\n }\n return;\n }\n\n const numberInQueue = total_count + 1;\n if (numberInQueue === 1 || data.find(label => label.name === FIRST_QUEUED_PR_LABEL)) {\n await setCommitStatus({\n sha,\n context: 'QUEUE CHECKER',\n state: 'success'\n });\n }\n return octokit.issues.addLabels({\n labels: [`${QUEUED_FOR_MERGE_PREFIX} #${numberInQueue}`],\n issue_number,\n ...context.repo\n });\n};\n\nconst updateMergeQueue = async (queuedPrs: IssuesAndPullRequestsResponse['data']['items']) => {\n return map(queuedPrs, pr => {\n const mergeLabel = pr.labels.find(label => label.name?.startsWith(QUEUED_FOR_MERGE_PREFIX))?.name;\n if (!mergeLabel) {\n return;\n }\n const pull_number = String(pr.number);\n const queueNumber = Number(mergeLabel.split('#')[1]);\n return Promise.all([\n addLabels({ pull_number, labels: `${QUEUED_FOR_MERGE_PREFIX} #${queueNumber - 1}` }),\n removeLabel({ pull_number, label: mergeLabel })\n ]);\n });\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 { context } from '@actions/github';\nimport { octokit } from '../octokit';\n\ninterface RemoveLabel {\n label: string;\n pull_number: string;\n}\n\nexport const removeLabel = ({ label, pull_number }: RemoveLabel) =>\n octokit.issues\n .removeLabel({\n name: label,\n issue_number: Number(pull_number),\n ...context.repo\n })\n .catch(error => {\n if (error.status === 404) {\n core.info('Label is not present on PR.');\n }\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 { PipelineState } from '../types';\nimport { context as githubContext } from '@actions/github';\nimport { map } from 'bluebird';\nimport { octokit } from '../octokit';\n\ninterface SetCommitStatus {\n sha: string;\n context: string;\n state: PipelineState;\n description?: string;\n target_url?: string;\n}\n\nexport const setCommitStatus = ({ sha, context, state, description, target_url }: SetCommitStatus) =>\n map(context.split('\\n'), context =>\n octokit.repos.createCommitStatus({\n sha,\n context,\n state,\n description,\n target_url,\n ...githubContext.repo\n })\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 { Octokit } from '@octokit/rest';\nimport { getOctokit } from '@actions/github';\n\nexport const octokit = getOctokit(core.getInput('github_token', { required: true })).rest as unknown as Octokit;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;;;;;;;;AC/BA;;;;;;;;;;;AAWA;AAEA;AACA;AAOA;;;A;;;;;;;;;;;;;;;;;;;;;;;;;ACrBA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;ACTA;;;;;;;;;;;AAWA;;;;;;;;;;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;;AACA;AAGA;AACA;AACA;AACA;AAEA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AAEA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;;;;;;;;;;AC/EA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AAOA,4IAEA;AAKA;AACA;AACA;AACA;AACA;;;A;;;;;;;;;;;;;;;ACjCA;;;;;;;;;;;AAWA;AAGA;AACA;AACA;AAUA;AAIA;AACA;AACA;AACA;;;A;;;;;;;;;;;;;ACjCA;;;;;;;;;;;AAWA;AAEA;AAEA;AAEA;;;A;;;A","sourceRoot":""} \ No newline at end of file diff --git a/dist/898.index.js b/dist/898.index.js deleted file mode 100644 index 016d4a6bf..000000000 --- a/dist/898.index.js +++ /dev/null @@ -1,301 +0,0 @@ -exports.id = 898; -exports.ids = [898,939,61,209]; -exports.modules = { - -/***/ 9042: -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "Cc": () => (/* binding */ GITHUB_OPTIONS), -/* harmony export */ "$9": () => (/* binding */ DEFAULT_PIPELINE_STATUS), -/* harmony export */ "Km": () => (/* binding */ DEFAULT_PIPELINE_DESCRIPTION), -/* harmony export */ "Hc": () => (/* binding */ PRODUCTION_ENVIRONMENT), -/* harmony export */ "mj": () => (/* binding */ DEFAULT_BRANCH), -/* harmony export */ "_d": () => (/* binding */ CORE_APPROVED_PR_LABEL), -/* harmony export */ "Xt": () => (/* binding */ PEER_APPROVED_PR_LABEL), -/* harmony export */ "Ak": () => (/* binding */ READY_FOR_MERGE_PR_LABEL), -/* harmony export */ "Ee": () => (/* binding */ QUEUED_FOR_MERGE_PREFIX), -/* harmony export */ "IH": () => (/* binding */ FIRST_QUEUED_PR_LABEL), -/* harmony export */ "nJ": () => (/* binding */ JUMP_THE_QUEUE_PR_LABEL), -/* harmony export */ "HW": () => (/* binding */ DEFAULT_PR_TITLE_REGEX) -/* harmony export */ }); -/* unused harmony export DEFAULT_EXEMPT_DESCRIPTION */ -/* -Copyright 2021 Expedia, Inc. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - https://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -// These extra headers are for experimental operations. Newer versions of octokit may not require this -const GITHUB_OPTIONS = { - headers: { - accept: 'application/vnd.github.ant-man-preview+json,application/vnd.github.flash-preview+json,application/vnd.github.v3+json' - } -}; -const DEFAULT_EXEMPT_DESCRIPTION = 'Passed in case the check is exempt.'; -const DEFAULT_PIPELINE_STATUS = 'Pipeline Status'; -const DEFAULT_PIPELINE_DESCRIPTION = 'Pipeline clear.'; -const PRODUCTION_ENVIRONMENT = 'production'; -const DEFAULT_BRANCH = 'main'; -const CORE_APPROVED_PR_LABEL = 'CORE APPROVED'; -const PEER_APPROVED_PR_LABEL = 'PEER APPROVED'; -const READY_FOR_MERGE_PR_LABEL = 'READY FOR MERGE'; -const QUEUED_FOR_MERGE_PREFIX = 'QUEUED FOR MERGE'; -const FIRST_QUEUED_PR_LABEL = `${QUEUED_FOR_MERGE_PREFIX} #1`; -const JUMP_THE_QUEUE_PR_LABEL = 'JUMP THE QUEUE'; -const DEFAULT_PR_TITLE_REGEX = '^(build|ci|chore|docs|feat|fix|perf|refactor|style|test|revert|Revert|BREAKING CHANGE)((.*))?: .+$'; - - -/***/ }), - -/***/ 1939: -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "addLabels": () => (/* binding */ addLabels) -/* harmony export */ }); -/* 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); -/* -Copyright 2021 Expedia, Inc. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - https://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - - -const addLabels = ({ pull_number, labels }) => _octokit__WEBPACK_IMPORTED_MODULE_1__/* .octokit.issues.addLabels */ .K.issues.addLabels(Object.assign({ labels: labels.split('\n'), issue_number: Number(pull_number) }, _actions_github__WEBPACK_IMPORTED_MODULE_0__.context.repo)); - - -/***/ }), - -/***/ 6898: -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "manageMergeQueue": () => (/* binding */ manageMergeQueue) -/* 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 _constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9042); -/* harmony import */ var _add_labels__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1939); -/* harmony import */ var _actions_github__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5438); -/* harmony import */ var _actions_github__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_actions_github__WEBPACK_IMPORTED_MODULE_3__); -/* harmony import */ var bluebird__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(8710); -/* harmony import */ var bluebird__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(bluebird__WEBPACK_IMPORTED_MODULE_4__); -/* harmony import */ var _octokit__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6161); -/* harmony import */ var _remove_label__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(61); -/* harmony import */ var _set_commit_status__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(2209); -/* -Copyright 2021 Expedia, Inc. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - https://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; - - - - - - - - -const manageMergeQueue = ({ event }) => __awaiter(void 0, void 0, void 0, function* () { - var _a, _b; - const pull_request = JSON.parse(event).pull_request; - const { data: { items, total_count } } = yield getQueuedPrData(); - const issue_number = _actions_github__WEBPACK_IMPORTED_MODULE_3__.context.issue.number; - if (pull_request.merged) { - const queueLabel = (_a = pull_request.labels.find(label => { var _a; return (_a = label.name) === null || _a === void 0 ? void 0 : _a.startsWith(_constants__WEBPACK_IMPORTED_MODULE_1__/* .QUEUED_FOR_MERGE_PREFIX */ .Ee); })) === null || _a === void 0 ? void 0 : _a.name; - if (queueLabel) { - yield (0,_remove_label__WEBPACK_IMPORTED_MODULE_6__.removeLabel)({ label: queueLabel, pull_number: String(issue_number) }); - yield updateMergeQueue(items); - } - return; - } - const { data } = yield _octokit__WEBPACK_IMPORTED_MODULE_5__/* .octokit.issues.listLabelsOnIssue */ .K.issues.listLabelsOnIssue(Object.assign({ issue_number }, _actions_github__WEBPACK_IMPORTED_MODULE_3__.context.repo)); - if (!data.find(label => label.name === _constants__WEBPACK_IMPORTED_MODULE_1__/* .READY_FOR_MERGE_PR_LABEL */ .Ak)) { - _actions_core__WEBPACK_IMPORTED_MODULE_0__.info('PR is not ready for merge.'); - const queueLabel = (_b = data.find(label => label.name.startsWith(_constants__WEBPACK_IMPORTED_MODULE_1__/* .QUEUED_FOR_MERGE_PREFIX */ .Ee))) === null || _b === void 0 ? void 0 : _b.name; - if (queueLabel) { - yield (0,_remove_label__WEBPACK_IMPORTED_MODULE_6__.removeLabel)({ label: queueLabel, pull_number: String(issue_number) }); - yield updateMergeQueue(items); - } - return; - } - const numberInQueue = total_count + 1; - if (numberInQueue === 1 || data.find(label => label.name === _constants__WEBPACK_IMPORTED_MODULE_1__/* .FIRST_QUEUED_PR_LABEL */ .IH)) { - yield (0,_set_commit_status__WEBPACK_IMPORTED_MODULE_7__.setCommitStatus)({ - sha: pull_request.head.sha, - context: 'QUEUE CHECKER', - state: 'success' - }); - } - return _octokit__WEBPACK_IMPORTED_MODULE_5__/* .octokit.issues.addLabels */ .K.issues.addLabels(Object.assign({ labels: [`${_constants__WEBPACK_IMPORTED_MODULE_1__/* .QUEUED_FOR_MERGE_PREFIX */ .Ee} #${numberInQueue}`], issue_number }, _actions_github__WEBPACK_IMPORTED_MODULE_3__.context.repo)); -}); -const updateMergeQueue = (queuedPrs) => { - return (0,bluebird__WEBPACK_IMPORTED_MODULE_4__.map)(queuedPrs, pr => { - var _a; - const queueLabel = (_a = pr.labels.find(label => { var _a; return (_a = label.name) === null || _a === void 0 ? void 0 : _a.startsWith(_constants__WEBPACK_IMPORTED_MODULE_1__/* .QUEUED_FOR_MERGE_PREFIX */ .Ee); })) === null || _a === void 0 ? void 0 : _a.name; - if (!queueLabel) { - return; - } - const pull_number = String(pr.number); - const queueNumber = Number(queueLabel.split('#')[1]); - return Promise.all([ - (0,_add_labels__WEBPACK_IMPORTED_MODULE_2__.addLabels)({ pull_number, labels: `${_constants__WEBPACK_IMPORTED_MODULE_1__/* .QUEUED_FOR_MERGE_PREFIX */ .Ee} #${queueNumber - 1}` }), - (0,_remove_label__WEBPACK_IMPORTED_MODULE_6__.removeLabel)({ pull_number, label: queueLabel }) - ]); - }); -}; -const getQueuedPrData = () => { - const { repo, owner } = _actions_github__WEBPACK_IMPORTED_MODULE_3__.context.repo; - return _octokit__WEBPACK_IMPORTED_MODULE_5__/* .octokit.search.issuesAndPullRequests */ .K.search.issuesAndPullRequests({ - q: encodeURIComponent(`org:${owner} repo:${repo} type:pr state:open label:"${_constants__WEBPACK_IMPORTED_MODULE_1__/* .QUEUED_FOR_MERGE_PREFIX */ .Ee}"`) - }); -}; - - -/***/ }), - -/***/ 61: -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "removeLabel": () => (/* binding */ removeLabel) -/* 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 _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); -/* -Copyright 2021 Expedia, Inc. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - https://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - - - -const removeLabel = ({ label, pull_number }) => _octokit__WEBPACK_IMPORTED_MODULE_2__/* .octokit.issues.removeLabel */ .K.issues.removeLabel(Object.assign({ name: label, issue_number: Number(pull_number) }, _actions_github__WEBPACK_IMPORTED_MODULE_1__.context.repo)) - .catch(error => { - if (error.status === 404) { - _actions_core__WEBPACK_IMPORTED_MODULE_0__.info('Label is not present on PR.'); - } -}); - - -/***/ }), - -/***/ 2209: -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "setCommitStatus": () => (/* binding */ setCommitStatus) -/* harmony export */ }); -/* 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 bluebird__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8710); -/* harmony import */ var bluebird__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(bluebird__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var _octokit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6161); -/* -Copyright 2021 Expedia, Inc. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - https://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - - - -const setCommitStatus = ({ sha, context, state, description, target_url }) => (0,bluebird__WEBPACK_IMPORTED_MODULE_1__.map)(context.split('\n'), context => _octokit__WEBPACK_IMPORTED_MODULE_2__/* .octokit.repos.createCommitStatus */ .K.repos.createCommitStatus(Object.assign({ sha, - context, - state, - description, - target_url }, _actions_github__WEBPACK_IMPORTED_MODULE_0__.context.repo))); - - -/***/ }), - -/***/ 6161: -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "K": () => (/* binding */ octokit) -/* 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 _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__); -/* -Copyright 2021 Expedia, Inc. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - https://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - - -const octokit = (0,_actions_github__WEBPACK_IMPORTED_MODULE_1__.getOctokit)(_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput('github_token', { required: true })).rest; - - -/***/ }) - -}; -; -//# sourceMappingURL=898.index.js.map \ No newline at end of file diff --git a/dist/898.index.js.map b/dist/898.index.js.map deleted file mode 100644 index 9521cd7f1..000000000 --- a/dist/898.index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"898.index.js","sources":["webpack://github-helpers/./src/constants.ts","webpack://github-helpers/./src/helpers/add-labels.ts","webpack://github-helpers/./src/helpers/manage-merge-queue.ts","webpack://github-helpers/./src/helpers/remove-label.ts","webpack://github-helpers/./src/helpers/set-commit-status.ts","webpack://github-helpers/./src/octokit.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\n// These extra headers are for experimental operations. Newer versions of octokit may not require this\nexport const GITHUB_OPTIONS = {\n headers: {\n accept: 'application/vnd.github.ant-man-preview+json,application/vnd.github.flash-preview+json,application/vnd.github.v3+json'\n }\n};\n\nexport const DEFAULT_EXEMPT_DESCRIPTION = 'Passed in case the check is exempt.';\nexport const DEFAULT_PIPELINE_STATUS = 'Pipeline Status';\nexport const DEFAULT_PIPELINE_DESCRIPTION = 'Pipeline clear.';\nexport const PRODUCTION_ENVIRONMENT = 'production';\nexport const DEFAULT_BRANCH = 'main';\nexport const CORE_APPROVED_PR_LABEL = 'CORE APPROVED';\nexport const PEER_APPROVED_PR_LABEL = 'PEER APPROVED';\nexport const READY_FOR_MERGE_PR_LABEL = 'READY FOR MERGE';\nexport const QUEUED_FOR_MERGE_PREFIX = 'QUEUED FOR MERGE';\nexport const FIRST_QUEUED_PR_LABEL = `${QUEUED_FOR_MERGE_PREFIX} #1`;\nexport const JUMP_THE_QUEUE_PR_LABEL = 'JUMP THE QUEUE';\nexport const DEFAULT_PR_TITLE_REGEX = '^(build|ci|chore|docs|feat|fix|perf|refactor|style|test|revert|Revert|BREAKING CHANGE)((.*))?: .+$';\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 { context } from '@actions/github';\nimport { octokit } from '../octokit';\n\ninterface AddLabels {\n pull_number: string;\n labels: string;\n}\n\nexport const addLabels = ({ pull_number, labels }: AddLabels) =>\n octokit.issues.addLabels({\n labels: labels.split('\\n'),\n issue_number: Number(pull_number),\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 { FIRST_QUEUED_PR_LABEL, QUEUED_FOR_MERGE_PREFIX, READY_FOR_MERGE_PR_LABEL } from '../constants';\nimport { IssuesAndPullRequestsResponse, NewPullRequest } from '../types';\nimport { addLabels } from './add-labels';\nimport { context } from '@actions/github';\nimport { map } from 'bluebird';\nimport { octokit } from '../octokit';\nimport { removeLabel } from './remove-label';\nimport { setCommitStatus } from './set-commit-status';\n\ninterface ManageMergeQueue {\n event: string;\n}\n\nexport const manageMergeQueue = async ({ event }: ManageMergeQueue) => {\n const pull_request = JSON.parse(event).pull_request as NewPullRequest;\n const {\n data: { items, total_count }\n } = await getQueuedPrData();\n const issue_number = context.issue.number;\n if (pull_request.merged) {\n const queueLabel = pull_request.labels.find(label => label.name?.startsWith(QUEUED_FOR_MERGE_PREFIX))?.name;\n if (queueLabel) {\n await removeLabel({ label: queueLabel, pull_number: String(issue_number) });\n await updateMergeQueue(items);\n }\n return;\n }\n\n const { data } = await octokit.issues.listLabelsOnIssue({\n issue_number,\n ...context.repo\n });\n if (!data.find(label => label.name === READY_FOR_MERGE_PR_LABEL)) {\n core.info('PR is not ready for merge.');\n const queueLabel = data.find(label => label.name.startsWith(QUEUED_FOR_MERGE_PREFIX))?.name;\n if (queueLabel) {\n await removeLabel({ label: queueLabel, pull_number: String(issue_number) });\n await updateMergeQueue(items);\n }\n return;\n }\n\n const numberInQueue = total_count + 1;\n if (numberInQueue === 1 || data.find(label => label.name === FIRST_QUEUED_PR_LABEL)) {\n await setCommitStatus({\n sha: pull_request.head.sha,\n context: 'QUEUE CHECKER',\n state: 'success'\n });\n }\n return octokit.issues.addLabels({\n labels: [`${QUEUED_FOR_MERGE_PREFIX} #${numberInQueue}`],\n issue_number,\n ...context.repo\n });\n};\n\nconst updateMergeQueue = (queuedPrs: IssuesAndPullRequestsResponse['data']['items']) => {\n return map(queuedPrs, pr => {\n const queueLabel = pr.labels.find(label => label.name?.startsWith(QUEUED_FOR_MERGE_PREFIX))?.name;\n if (!queueLabel) {\n return;\n }\n const pull_number = String(pr.number);\n const queueNumber = Number(queueLabel.split('#')[1]);\n return Promise.all([\n addLabels({ pull_number, labels: `${QUEUED_FOR_MERGE_PREFIX} #${queueNumber - 1}` }),\n removeLabel({ pull_number, label: queueLabel })\n ]);\n });\n};\n\nconst getQueuedPrData = () => {\n const { repo, owner } = context.repo;\n return octokit.search.issuesAndPullRequests({\n q: encodeURIComponent(`org:${owner} repo:${repo} type:pr state:open label:\"${QUEUED_FOR_MERGE_PREFIX}\"`)\n });\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 { context } from '@actions/github';\nimport { octokit } from '../octokit';\n\ninterface RemoveLabel {\n label: string;\n pull_number: string;\n}\n\nexport const removeLabel = ({ label, pull_number }: RemoveLabel) =>\n octokit.issues\n .removeLabel({\n name: label,\n issue_number: Number(pull_number),\n ...context.repo\n })\n .catch(error => {\n if (error.status === 404) {\n core.info('Label is not present on PR.');\n }\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 { PipelineState } from '../types';\nimport { context as githubContext } from '@actions/github';\nimport { map } from 'bluebird';\nimport { octokit } from '../octokit';\n\ninterface SetCommitStatus {\n sha: string;\n context: string;\n state: PipelineState;\n description?: string;\n target_url?: string;\n}\n\nexport const setCommitStatus = ({ sha, context, state, description, target_url }: SetCommitStatus) =>\n map(context.split('\\n'), context =>\n octokit.repos.createCommitStatus({\n sha,\n context,\n state,\n description,\n target_url,\n ...githubContext.repo\n })\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 { Octokit } from '@octokit/rest';\nimport { getOctokit } from '@actions/github';\n\nexport const octokit = getOctokit(core.getInput('github_token', { required: true })).rest as unknown as Octokit;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;;;;;;;;AC/BA;;;;;;;;;;;AAWA;AAEA;AACA;AAOA;;;A;;;;;;;;;;;;;;;;;;;;;ACrBA;;;;;;;;;;;AAWA;;;;;;;;;;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAMA;;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AAEA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;;;;;;;;;;AC3FA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AAOA;AAOA;AACA;AACA;AACA;AACA;;;A;;;;;;;;;;;;;;;ACjCA;;;;;;;;;;;AAWA;AAGA;AACA;AACA;AAUA;AAIA;AACA;AACA;AACA;;;A;;;;;;;;;;;;;ACjCA;;;;;;;;;;;AAWA;AAEA;AAEA;AAEA;;;A;;;A","sourceRoot":""} \ No newline at end of file diff --git a/package.json b/package.json index 5ef35aeea..1e3223090 100644 --- a/package.json +++ b/package.json @@ -56,10 +56,11 @@ }, "scripts": { "build": "tsc", + "clean": "rm -rf build dist", "format": "prettier --write ./**/**/*.ts", "format-check": "prettier --check **/*.ts", "lint": "eslint --fix src/**/*.ts test/**/*.ts", - "package": "ncc build --source-map --license licenses.txt && cp action.yml dist", + "package": "npm run clean && ncc build --source-map --license licenses.txt && cp action.yml dist", "prepare": "husky install", "test": "jest" }