From ca2240b832a880a698189d6dfa734c76fe73026e Mon Sep 17 00:00:00 2001 From: pongraczl <48865727+pongraczl@users.noreply.github.com> Date: Mon, 31 Jan 2022 15:51:50 +0100 Subject: [PATCH] fix(initiate-deployment): add auto_merge parameter (#106) --- dist/420.index.js | 2 +- dist/420.index.js.map | 2 +- src/helpers/initiate-deployment.ts | 1 + test/helpers/initiate-deployment.test.ts | 2 ++ 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/dist/420.index.js b/dist/420.index.js index 0aeb5c826..1c6553809 100644 --- a/dist/420.index.js +++ b/dist/420.index.js @@ -99,7 +99,7 @@ class InitiateDeployment { } } const initiateDeployment = ({ sha, state = 'in_progress', environment, environment_url, description, target_url }) => __awaiter(void 0, void 0, void 0, function* () { - const { data } = yield _octokit__WEBPACK_IMPORTED_MODULE_2__/* .octokit.repos.createDeployment */ .K.repos.createDeployment(Object.assign(Object.assign({ ref: sha, environment, required_contexts: [] }, _actions_github__WEBPACK_IMPORTED_MODULE_1__.context.repo), _constants__WEBPACK_IMPORTED_MODULE_0__/* .GITHUB_OPTIONS */ .Cc)); + const { data } = yield _octokit__WEBPACK_IMPORTED_MODULE_2__/* .octokit.repos.createDeployment */ .K.repos.createDeployment(Object.assign(Object.assign({ ref: sha, environment, auto_merge: false, required_contexts: [] }, _actions_github__WEBPACK_IMPORTED_MODULE_1__.context.repo), _constants__WEBPACK_IMPORTED_MODULE_0__/* .GITHUB_OPTIONS */ .Cc)); const deployment_id = data.id; return _octokit__WEBPACK_IMPORTED_MODULE_2__/* .octokit.repos.createDeploymentStatus */ .K.repos.createDeploymentStatus(Object.assign(Object.assign({ state, deployment_id, diff --git a/dist/420.index.js.map b/dist/420.index.js.map index a0d0bcfd7..f51ae5d78 100644 --- a/dist/420.index.js.map +++ b/dist/420.index.js.map @@ -1 +1 @@ -{"version":3,"file":"420.index.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;AChCA;;;;;;;;;;;AAWA;;;;;;;;;;AAGA;AACA;AACA;AAEA;AAAA;AACA;AACA;AAKA;AAAA;AAEA;AAQA;AAOA;AACA;AAEA;AACA;AACA;AACA;AAIA;;;;;;;;;;;;;;;ACpDA;;;;;;;;;;;AAWA;AAEA;AAEA;AAEA","sources":["webpack://github-helpers/./src/constants.ts","webpack://github-helpers/./src/helpers/initiate-deployment.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 API features on Github Enterprise. See https://docs.github.com/en/enterprise-server@3.0/rest/overview/api-previews for details.\nconst PREVIEWS = ['ant-man', 'flash', 'groot', 'inertia', 'starfox'];\nexport const GITHUB_OPTIONS = {\n headers: {\n accept: PREVIEWS.map(preview => `application/vnd.github.${preview}-preview+json`).join()\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 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 MERGE_QUEUE_STATUS = 'QUEUE CHECKER';\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 { CreateDeploymentResponse, DeploymentState } from '../types';\nimport { GITHUB_OPTIONS } from '../constants';\nimport { context } from '@actions/github';\nimport { octokit } from '../octokit';\n\nexport class InitiateDeployment {\n sha = '';\n environment = '';\n state?: DeploymentState;\n environment_url?: string;\n description?: string;\n target_url?: string;\n}\n\nexport const initiateDeployment = async ({\n sha,\n state = 'in_progress',\n environment,\n environment_url,\n description,\n target_url\n}: InitiateDeployment) => {\n const { data } = await octokit.repos.createDeployment({\n ref: sha,\n environment,\n required_contexts: [],\n ...context.repo,\n ...GITHUB_OPTIONS\n });\n const deployment_id = (data as CreateDeploymentResponse).id;\n return octokit.repos.createDeploymentStatus({\n state,\n deployment_id,\n description,\n environment_url,\n target_url,\n ...context.repo,\n ...GITHUB_OPTIONS\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"],"names":[],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"420.index.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;AChCA;;;;;;;;;;;AAWA;;;;;;;;;;AAGA;AACA;AACA;AAEA;AAAA;AACA;AACA;AAKA;AAAA;AAEA;AAQA;AAQA;AACA;AAEA;AACA;AACA;AACA;AAIA;;;;;;;;;;;;;;;ACrDA;;;;;;;;;;;AAWA;AAEA;AAEA;AAEA","sources":["webpack://github-helpers/./src/constants.ts","webpack://github-helpers/./src/helpers/initiate-deployment.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 API features on Github Enterprise. See https://docs.github.com/en/enterprise-server@3.0/rest/overview/api-previews for details.\nconst PREVIEWS = ['ant-man', 'flash', 'groot', 'inertia', 'starfox'];\nexport const GITHUB_OPTIONS = {\n headers: {\n accept: PREVIEWS.map(preview => `application/vnd.github.${preview}-preview+json`).join()\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 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 MERGE_QUEUE_STATUS = 'QUEUE CHECKER';\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 { CreateDeploymentResponse, DeploymentState } from '../types';\nimport { GITHUB_OPTIONS } from '../constants';\nimport { context } from '@actions/github';\nimport { octokit } from '../octokit';\n\nexport class InitiateDeployment {\n sha = '';\n environment = '';\n state?: DeploymentState;\n environment_url?: string;\n description?: string;\n target_url?: string;\n}\n\nexport const initiateDeployment = async ({\n sha,\n state = 'in_progress',\n environment,\n environment_url,\n description,\n target_url\n}: InitiateDeployment) => {\n const { data } = await octokit.repos.createDeployment({\n ref: sha,\n environment,\n auto_merge: false,\n required_contexts: [],\n ...context.repo,\n ...GITHUB_OPTIONS\n });\n const deployment_id = (data as CreateDeploymentResponse).id;\n return octokit.repos.createDeploymentStatus({\n state,\n deployment_id,\n description,\n environment_url,\n target_url,\n ...context.repo,\n ...GITHUB_OPTIONS\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"],"names":[],"sourceRoot":""} \ No newline at end of file diff --git a/src/helpers/initiate-deployment.ts b/src/helpers/initiate-deployment.ts index b1f887cde..2fe8b6ed7 100644 --- a/src/helpers/initiate-deployment.ts +++ b/src/helpers/initiate-deployment.ts @@ -36,6 +36,7 @@ export const initiateDeployment = async ({ const { data } = await octokit.repos.createDeployment({ ref: sha, environment, + auto_merge: false, required_contexts: [], ...context.repo, ...GITHUB_OPTIONS diff --git a/test/helpers/initiate-deployment.test.ts b/test/helpers/initiate-deployment.test.ts index 193df26a3..3e90a7cd0 100644 --- a/test/helpers/initiate-deployment.test.ts +++ b/test/helpers/initiate-deployment.test.ts @@ -42,6 +42,7 @@ describe('initiateDeployment', () => { const environment = 'env'; const description = 'desc'; const target_url = 'url'; + const auto_merge = false; beforeEach(() => { initiateDeployment({ @@ -56,6 +57,7 @@ describe('initiateDeployment', () => { expect(octokit.repos.createDeployment).toHaveBeenCalledWith({ ref: sha, environment, + auto_merge, required_contexts: [], ...context.repo, ...GITHUB_OPTIONS