From 79d19b8cc6070af529e2da2dea9ea1f8a3889c64 Mon Sep 17 00:00:00 2001 From: Salvador Gonzalez Date: Thu, 9 Dec 2021 19:49:38 -0600 Subject: [PATCH] fix: adds required header for experimental project helpers (#30) --- dist/0.index.js | 2 +- dist/0.index.js.map | 2 +- dist/101.index.js | 2 +- dist/101.index.js.map | 2 +- dist/4.index.js | 2 +- dist/4.index.js.map | 2 +- dist/420.index.js | 2 +- dist/420.index.js.map | 2 +- dist/807.index.js | 2 +- dist/807.index.js.map | 2 +- dist/905.index.js | 2 +- dist/905.index.js.map | 2 +- dist/956.index.js | 2 +- dist/956.index.js.map | 2 +- src/constants.ts | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/dist/0.index.js b/dist/0.index.js index dbbed263d..5a4cf7531 100644 --- a/dist/0.index.js +++ b/dist/0.index.js @@ -35,7 +35,7 @@ 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' + 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.'; diff --git a/dist/0.index.js.map b/dist/0.index.js.map index c722b8534..45d2dd1f8 100644 --- a/dist/0.index.js.map +++ b/dist/0.index.js.map @@ -1 +1 @@ -{"version":3,"file":"0.index.js","sources":["webpack://github-helpers/./src/constants.ts","webpack://github-helpers/./src/helpers/set-latest-pipeline-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'\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 FIRST_QUEUED_PR_LABEL = 'QUEUED FOR MERGE #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)((.*))?: .+$';\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 { DEFAULT_PIPELINE_STATUS, GITHUB_OPTIONS, PRODUCTION_ENVIRONMENT } from '../constants';\nimport { PipelineState } from '../types';\nimport { context as githubContext } from '@actions/github';\nimport { octokit } from '../octokit';\n\ninterface SetLatestPipelineStatus {\n sha: string;\n context?: string;\n environment?: string;\n}\n\nexport const setLatestPipelineStatus = ({\n sha,\n context = DEFAULT_PIPELINE_STATUS,\n environment = PRODUCTION_ENVIRONMENT\n}: SetLatestPipelineStatus) =>\n octokit.repos\n .listDeployments({\n environment,\n ...githubContext.repo,\n ...GITHUB_OPTIONS\n })\n .then(deploymentsResponse => {\n const deployment_id = deploymentsResponse.data.find(Boolean)?.id;\n if (!deployment_id) {\n core.setFailed('No deployments found.');\n throw new Error();\n }\n return octokit.repos.listDeploymentStatuses({\n deployment_id,\n ...githubContext.repo,\n ...GITHUB_OPTIONS\n });\n })\n .then(deploymentStatusResponse => deploymentStatusResponse.data.find(Boolean))\n .then(deploymentStatus => {\n if (!deploymentStatus) {\n core.setFailed('No deployment statuses found.');\n throw new Error();\n }\n return octokit.repos.createCommitStatus({\n sha,\n context,\n state: deploymentStateToPipelineStateMap[deploymentStatus.state],\n description: deploymentStatus.description,\n target_url: deploymentStatus.target_url,\n ...githubContext.repo\n });\n });\n\nconst deploymentStateToPipelineStateMap: { [deploymentState: string]: PipelineState } = {\n in_progress: 'pending',\n success: 'success',\n failure: 'failure',\n inactive: 'error'\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;;;A;;;;;;;;;;;;;;;;AC9BA;;;;;;;;;;;AAWA;AAEA;AACA;AAEA;AACA;AAQA,4TAMA;AAKA;;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAMA;AAEA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;;;;;;;;ACrEA;;;;;;;;;;;AAWA;AAEA;AAEA;AAEA;;;A;;;A","sourceRoot":""} \ No newline at end of file +{"version":3,"file":"0.index.js","sources":["webpack://github-helpers/./src/constants.ts","webpack://github-helpers/./src/helpers/set-latest-pipeline-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 FIRST_QUEUED_PR_LABEL = 'QUEUED FOR MERGE #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)((.*))?: .+$';\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 { DEFAULT_PIPELINE_STATUS, GITHUB_OPTIONS, PRODUCTION_ENVIRONMENT } from '../constants';\nimport { PipelineState } from '../types';\nimport { context as githubContext } from '@actions/github';\nimport { octokit } from '../octokit';\n\ninterface SetLatestPipelineStatus {\n sha: string;\n context?: string;\n environment?: string;\n}\n\nexport const setLatestPipelineStatus = ({\n sha,\n context = DEFAULT_PIPELINE_STATUS,\n environment = PRODUCTION_ENVIRONMENT\n}: SetLatestPipelineStatus) =>\n octokit.repos\n .listDeployments({\n environment,\n ...githubContext.repo,\n ...GITHUB_OPTIONS\n })\n .then(deploymentsResponse => {\n const deployment_id = deploymentsResponse.data.find(Boolean)?.id;\n if (!deployment_id) {\n core.setFailed('No deployments found.');\n throw new Error();\n }\n return octokit.repos.listDeploymentStatuses({\n deployment_id,\n ...githubContext.repo,\n ...GITHUB_OPTIONS\n });\n })\n .then(deploymentStatusResponse => deploymentStatusResponse.data.find(Boolean))\n .then(deploymentStatus => {\n if (!deploymentStatus) {\n core.setFailed('No deployment statuses found.');\n throw new Error();\n }\n return octokit.repos.createCommitStatus({\n sha,\n context,\n state: deploymentStateToPipelineStateMap[deploymentStatus.state],\n description: deploymentStatus.description,\n target_url: deploymentStatus.target_url,\n ...githubContext.repo\n });\n });\n\nconst deploymentStateToPipelineStateMap: { [deploymentState: string]: PipelineState } = {\n in_progress: 'pending',\n success: 'success',\n failure: 'failure',\n inactive: 'error'\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;;;A;;;;;;;;;;;;;;;;AC9BA;;;;;;;;;;;AAWA;AAEA;AACA;AAEA;AACA;AAQA,4TAMA;AAKA;;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAMA;AAEA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;;;;;;;;ACrEA;;;;;;;;;;;AAWA;AAEA;AAEA;AAEA;;;A;;;A","sourceRoot":""} \ No newline at end of file diff --git a/dist/101.index.js b/dist/101.index.js index 4b9a59677..a6f512c66 100644 --- a/dist/101.index.js +++ b/dist/101.index.js @@ -35,7 +35,7 @@ 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' + 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.'; diff --git a/dist/101.index.js.map b/dist/101.index.js.map index 6a77e800b..46f0e12ce 100644 --- a/dist/101.index.js.map +++ b/dist/101.index.js.map @@ -1 +1 @@ -{"version":3,"file":"101.index.js","sources":["webpack://github-helpers/./src/constants.ts","webpack://github-helpers/./src/helpers/notify-pipeline-complete.ts","webpack://github-helpers/./src/helpers/set-deployment-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'\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 FIRST_QUEUED_PR_LABEL = 'QUEUED FOR MERGE #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)((.*))?: .+$';\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 { DEFAULT_PIPELINE_DESCRIPTION, DEFAULT_PIPELINE_STATUS, PRODUCTION_ENVIRONMENT } from '../constants';\nimport { context as githubContext } from '@actions/github';\nimport { map } from 'bluebird';\nimport { octokit } from '../octokit';\nimport { setDeploymentStatus } from './set-deployment-status';\n\ninterface NotifyPipelineComplete {\n context?: string;\n description?: string;\n target_url?: string;\n}\n\nexport const notifyPipelineComplete = ({\n context = DEFAULT_PIPELINE_STATUS,\n description = DEFAULT_PIPELINE_DESCRIPTION,\n target_url\n}: NotifyPipelineComplete) =>\n Promise.all([\n octokit.pulls\n .list({\n state: 'open',\n per_page: 100,\n ...githubContext.repo\n })\n .then(pullRequestsResponse => {\n const commitHashes = pullRequestsResponse.data.map(pullRequest => pullRequest.head.sha);\n return map(commitHashes, sha =>\n octokit.repos.createCommitStatus({\n sha,\n context,\n state: 'success',\n description,\n target_url,\n ...githubContext.repo\n })\n );\n }),\n setDeploymentStatus({\n description: DEFAULT_PIPELINE_DESCRIPTION,\n environment: PRODUCTION_ENVIRONMENT,\n state: 'success',\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 { DeploymentState } from '../types';\nimport { GITHUB_OPTIONS } from '../constants';\nimport { context } from '@actions/github';\nimport { octokit } from '../octokit';\n\ninterface SetDeploymentStatus {\n state: DeploymentState;\n environment: string;\n sha?: string;\n description?: string;\n target_url?: string;\n environment_url?: string;\n}\n\nexport const setDeploymentStatus = ({ sha, state, environment, description, target_url, environment_url }: SetDeploymentStatus) =>\n octokit.repos\n .listDeployments({\n sha,\n environment,\n ...context.repo,\n ...GITHUB_OPTIONS\n })\n .then(deploymentsResponse => {\n const deployment_id = deploymentsResponse.data.find(Boolean)?.id;\n if (deployment_id) {\n return octokit.repos.createDeploymentStatus({\n state,\n deployment_id,\n description,\n target_url,\n environment_url,\n ...context.repo,\n ...GITHUB_OPTIONS\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;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;;;;;;;;;;;;AC9BA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AACA;AACA;AAQA;AAMA,gFACA;AAKA;AACA;AACA;AAGA;AAGA;AAIA;AACA;AAMA;;;A;;;;;;;;;;;;;;ACxDA;;;;;;;;;;;AAWA;AAGA;AACA;AACA;AAWA,yMAEA;AAEA;AAIA;;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAIA;AACA;;;A;;;;;;;;;;;;;AChDA;;;;;;;;;;;AAWA;AAEA;AAEA;AAEA;;;A;;;A","sourceRoot":""} \ No newline at end of file +{"version":3,"file":"101.index.js","sources":["webpack://github-helpers/./src/constants.ts","webpack://github-helpers/./src/helpers/notify-pipeline-complete.ts","webpack://github-helpers/./src/helpers/set-deployment-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 FIRST_QUEUED_PR_LABEL = 'QUEUED FOR MERGE #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)((.*))?: .+$';\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 { DEFAULT_PIPELINE_DESCRIPTION, DEFAULT_PIPELINE_STATUS, PRODUCTION_ENVIRONMENT } from '../constants';\nimport { context as githubContext } from '@actions/github';\nimport { map } from 'bluebird';\nimport { octokit } from '../octokit';\nimport { setDeploymentStatus } from './set-deployment-status';\n\ninterface NotifyPipelineComplete {\n context?: string;\n description?: string;\n target_url?: string;\n}\n\nexport const notifyPipelineComplete = ({\n context = DEFAULT_PIPELINE_STATUS,\n description = DEFAULT_PIPELINE_DESCRIPTION,\n target_url\n}: NotifyPipelineComplete) =>\n Promise.all([\n octokit.pulls\n .list({\n state: 'open',\n per_page: 100,\n ...githubContext.repo\n })\n .then(pullRequestsResponse => {\n const commitHashes = pullRequestsResponse.data.map(pullRequest => pullRequest.head.sha);\n return map(commitHashes, sha =>\n octokit.repos.createCommitStatus({\n sha,\n context,\n state: 'success',\n description,\n target_url,\n ...githubContext.repo\n })\n );\n }),\n setDeploymentStatus({\n description: DEFAULT_PIPELINE_DESCRIPTION,\n environment: PRODUCTION_ENVIRONMENT,\n state: 'success',\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 { DeploymentState } from '../types';\nimport { GITHUB_OPTIONS } from '../constants';\nimport { context } from '@actions/github';\nimport { octokit } from '../octokit';\n\ninterface SetDeploymentStatus {\n state: DeploymentState;\n environment: string;\n sha?: string;\n description?: string;\n target_url?: string;\n environment_url?: string;\n}\n\nexport const setDeploymentStatus = ({ sha, state, environment, description, target_url, environment_url }: SetDeploymentStatus) =>\n octokit.repos\n .listDeployments({\n sha,\n environment,\n ...context.repo,\n ...GITHUB_OPTIONS\n })\n .then(deploymentsResponse => {\n const deployment_id = deploymentsResponse.data.find(Boolean)?.id;\n if (deployment_id) {\n return octokit.repos.createDeploymentStatus({\n state,\n deployment_id,\n description,\n target_url,\n environment_url,\n ...context.repo,\n ...GITHUB_OPTIONS\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;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;;;;;;;;;;;;AC9BA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AACA;AACA;AAQA;AAMA,gFACA;AAKA;AACA;AACA;AAGA;AAGA;AAIA;AACA;AAMA;;;A;;;;;;;;;;;;;;ACxDA;;;;;;;;;;;AAWA;AAGA;AACA;AACA;AAWA,yMAEA;AAEA;AAIA;;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAIA;AACA;;;A;;;;;;;;;;;;;AChDA;;;;;;;;;;;AAWA;AAEA;AAEA;AAEA;;;A;;;A","sourceRoot":""} \ No newline at end of file diff --git a/dist/4.index.js b/dist/4.index.js index dda5e2346..fd6ac55f7 100644 --- a/dist/4.index.js +++ b/dist/4.index.js @@ -35,7 +35,7 @@ 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' + 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.'; diff --git a/dist/4.index.js.map b/dist/4.index.js.map index ee5109cac..49d712506 100644 --- a/dist/4.index.js.map +++ b/dist/4.index.js.map @@ -1 +1 @@ -{"version":3,"file":"4.index.js","sources":["webpack://github-helpers/./src/constants.ts","webpack://github-helpers/./src/helpers/create-pr-comment.ts","webpack://github-helpers/./src/helpers/prepare-queued-pr-for-merge.ts","webpack://github-helpers/./src/helpers/remove-label.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'\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 FIRST_QUEUED_PR_LABEL = 'QUEUED FOR MERGE #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)((.*))?: .+$';\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 CreatePrComment {\n body: string;\n pull_number: string;\n}\n\nexport const createPrComment = ({ body, pull_number }: CreatePrComment) =>\n octokit.issues.createComment({\n body,\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 { DEFAULT_BRANCH, FIRST_QUEUED_PR_LABEL, JUMP_THE_QUEUE_PR_LABEL, READY_FOR_MERGE_PR_LABEL } from '../constants';\nimport { PullRequest, PullRequestListResponse } from '../types';\nimport { context } from '@actions/github';\nimport { createPrComment } from './create-pr-comment';\nimport { octokit } from '../octokit';\nimport { removeLabel } from './remove-label';\n\ninterface PrepareQueuedPrForMerge {\n prevent_merge_conflicts?: string;\n default_branch?: string;\n}\n\nexport const prepareQueuedPrForMerge = ({ prevent_merge_conflicts, default_branch = DEFAULT_BRANCH }: PrepareQueuedPrForMerge) =>\n octokit.pulls\n .list({\n state: 'open',\n per_page: 100,\n ...context.repo\n })\n .then(findNextPrToMerge)\n .then(pullRequest => {\n if (pullRequest) {\n return octokit.repos\n .merge({\n base: pullRequest.head.ref,\n head: default_branch,\n ...context.repo\n })\n .catch(error => {\n if (error.status === 409 && Boolean(prevent_merge_conflicts)) {\n core.info('The next PR to merge has a conflict. Removing this PR from merge queue.');\n return Promise.all([\n createPrComment({\n body: 'This PR has a merge conflict, so it is being removed from the merge queue.',\n pull_number: String(pullRequest.number),\n ...context.repo\n }),\n removeLabel({\n label: READY_FOR_MERGE_PR_LABEL,\n pull_number: String(pullRequest.number),\n ...context.repo\n })\n ]);\n }\n });\n }\n });\n\nconst findNextPrToMerge = (pullRequestsResponse: PullRequestListResponse) =>\n pullRequestsResponse.data.find(pr => hasRequiredLabels(pr, [READY_FOR_MERGE_PR_LABEL, JUMP_THE_QUEUE_PR_LABEL])) ??\n pullRequestsResponse.data.find(pr => hasRequiredLabels(pr, [READY_FOR_MERGE_PR_LABEL, FIRST_QUEUED_PR_LABEL]));\n\nconst hasRequiredLabels = (pr: PullRequest, requiredLabels: string[]) =>\n requiredLabels.every(mergeQueueLabel => pr.labels.some(label => label.name === mergeQueueLabel));\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 * 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;;;A;;;;;;;;;;;;;AC9BA;;;;;;;;;;;AAWA;AAEA;AACA;AAOA;;;A;;;;;;;;;;;;;;;;;;ACrBA;;;;;;;;;;;AAWA;AAEA;AACA;AAEA;AACA;AACA;AACA;AAOA,gOAEA;AAKA;AACA;AACA;AACA,6FACA;AAKA;AACA;AACA;AACA;AACA;AAKA;AAKA;AACA;AACA;AACA;AACA;AAEA;;AACA;AACA;AAEA;;;A;;;;;;;;;;;;;;;AClEA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AAOA,4IAEA;AAKA;AACA;AACA;AACA;AACA;;;A;;;;;;;;;;;;;ACjCA;;;;;;;;;;;AAWA;AAEA;AAEA;AAEA;;;A;;;A","sourceRoot":""} \ No newline at end of file +{"version":3,"file":"4.index.js","sources":["webpack://github-helpers/./src/constants.ts","webpack://github-helpers/./src/helpers/create-pr-comment.ts","webpack://github-helpers/./src/helpers/prepare-queued-pr-for-merge.ts","webpack://github-helpers/./src/helpers/remove-label.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 FIRST_QUEUED_PR_LABEL = 'QUEUED FOR MERGE #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)((.*))?: .+$';\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 CreatePrComment {\n body: string;\n pull_number: string;\n}\n\nexport const createPrComment = ({ body, pull_number }: CreatePrComment) =>\n octokit.issues.createComment({\n body,\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 { DEFAULT_BRANCH, FIRST_QUEUED_PR_LABEL, JUMP_THE_QUEUE_PR_LABEL, READY_FOR_MERGE_PR_LABEL } from '../constants';\nimport { PullRequest, PullRequestListResponse } from '../types';\nimport { context } from '@actions/github';\nimport { createPrComment } from './create-pr-comment';\nimport { octokit } from '../octokit';\nimport { removeLabel } from './remove-label';\n\ninterface PrepareQueuedPrForMerge {\n prevent_merge_conflicts?: string;\n default_branch?: string;\n}\n\nexport const prepareQueuedPrForMerge = ({ prevent_merge_conflicts, default_branch = DEFAULT_BRANCH }: PrepareQueuedPrForMerge) =>\n octokit.pulls\n .list({\n state: 'open',\n per_page: 100,\n ...context.repo\n })\n .then(findNextPrToMerge)\n .then(pullRequest => {\n if (pullRequest) {\n return octokit.repos\n .merge({\n base: pullRequest.head.ref,\n head: default_branch,\n ...context.repo\n })\n .catch(error => {\n if (error.status === 409 && Boolean(prevent_merge_conflicts)) {\n core.info('The next PR to merge has a conflict. Removing this PR from merge queue.');\n return Promise.all([\n createPrComment({\n body: 'This PR has a merge conflict, so it is being removed from the merge queue.',\n pull_number: String(pullRequest.number),\n ...context.repo\n }),\n removeLabel({\n label: READY_FOR_MERGE_PR_LABEL,\n pull_number: String(pullRequest.number),\n ...context.repo\n })\n ]);\n }\n });\n }\n });\n\nconst findNextPrToMerge = (pullRequestsResponse: PullRequestListResponse) =>\n pullRequestsResponse.data.find(pr => hasRequiredLabels(pr, [READY_FOR_MERGE_PR_LABEL, JUMP_THE_QUEUE_PR_LABEL])) ??\n pullRequestsResponse.data.find(pr => hasRequiredLabels(pr, [READY_FOR_MERGE_PR_LABEL, FIRST_QUEUED_PR_LABEL]));\n\nconst hasRequiredLabels = (pr: PullRequest, requiredLabels: string[]) =>\n requiredLabels.every(mergeQueueLabel => pr.labels.some(label => label.name === mergeQueueLabel));\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 * 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;;;A;;;;;;;;;;;;;AC9BA;;;;;;;;;;;AAWA;AAEA;AACA;AAOA;;;A;;;;;;;;;;;;;;;;;;ACrBA;;;;;;;;;;;AAWA;AAEA;AACA;AAEA;AACA;AACA;AACA;AAOA,gOAEA;AAKA;AACA;AACA;AACA,6FACA;AAKA;AACA;AACA;AACA;AACA;AAKA;AAKA;AACA;AACA;AACA;AACA;AAEA;;AACA;AACA;AAEA;;;A;;;;;;;;;;;;;;;AClEA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AAOA,4IAEA;AAKA;AACA;AACA;AACA;AACA;;;A;;;;;;;;;;;;;ACjCA;;;;;;;;;;;AAWA;AAEA;AAEA;AAEA;;;A;;;A","sourceRoot":""} \ No newline at end of file diff --git a/dist/420.index.js b/dist/420.index.js index ffc692dba..58c508a95 100644 --- a/dist/420.index.js +++ b/dist/420.index.js @@ -35,7 +35,7 @@ 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' + 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.'; diff --git a/dist/420.index.js.map b/dist/420.index.js.map index 82f5bae84..10d156f8a 100644 --- a/dist/420.index.js.map +++ b/dist/420.index.js.map @@ -1 +1 @@ -{"version":3,"file":"420.index.js","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 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'\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 FIRST_QUEUED_PR_LABEL = 'QUEUED FOR MERGE #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)((.*))?: .+$';\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\ninterface InitiateDeployment {\n sha: string;\n environment: string;\n state?: DeploymentState;\n environment_url?: string;\n description?: string;\n target_url?: string;\n}\n\nexport const initiateDeployment = ({\n sha,\n state = 'in_progress',\n environment,\n environment_url,\n description,\n target_url\n}: InitiateDeployment) =>\n octokit.repos\n .createDeployment({\n ref: sha,\n environment,\n required_contexts: [],\n ...context.repo,\n ...GITHUB_OPTIONS\n })\n .then(newDeploymentResponse => {\n const deployment_id = (newDeploymentResponse.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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;;;;;;;;;AC9BA;;;;;;;;;;;AAWA;AAGA;AACA;AACA;AAWA,0NASA;AAOA;AACA;AACA;AAEA;AACA;AACA;AACA;AAIA;;;A;;;;;;;;;;;;;ACtDA;;;;;;;;;;;AAWA;AAEA;AAEA;AAEA;;;A;;;A","sourceRoot":""} \ No newline at end of file +{"version":3,"file":"420.index.js","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 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 FIRST_QUEUED_PR_LABEL = 'QUEUED FOR MERGE #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)((.*))?: .+$';\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\ninterface InitiateDeployment {\n sha: string;\n environment: string;\n state?: DeploymentState;\n environment_url?: string;\n description?: string;\n target_url?: string;\n}\n\nexport const initiateDeployment = ({\n sha,\n state = 'in_progress',\n environment,\n environment_url,\n description,\n target_url\n}: InitiateDeployment) =>\n octokit.repos\n .createDeployment({\n ref: sha,\n environment,\n required_contexts: [],\n ...context.repo,\n ...GITHUB_OPTIONS\n })\n .then(newDeploymentResponse => {\n const deployment_id = (newDeploymentResponse.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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;;;;;;;;;AC9BA;;;;;;;;;;;AAWA;AAGA;AACA;AACA;AAWA,0NASA;AAOA;AACA;AACA;AAEA;AACA;AACA;AACA;AAIA;;;A;;;;;;;;;;;;;ACtDA;;;;;;;;;;;AAWA;AAEA;AAEA;AAEA;;;A;;;A","sourceRoot":""} \ No newline at end of file diff --git a/dist/807.index.js b/dist/807.index.js index 371a2256e..4a597aaf6 100644 --- a/dist/807.index.js +++ b/dist/807.index.js @@ -35,7 +35,7 @@ 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' + 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.'; diff --git a/dist/807.index.js.map b/dist/807.index.js.map index 50e82e983..c4dda091a 100644 --- a/dist/807.index.js.map +++ b/dist/807.index.js.map @@ -1 +1 @@ -{"version":3,"file":"807.index.js","sources":["webpack://github-helpers/./src/constants.ts","webpack://github-helpers/./src/helpers/set-deployment-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'\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 FIRST_QUEUED_PR_LABEL = 'QUEUED FOR MERGE #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)((.*))?: .+$';\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 { DeploymentState } from '../types';\nimport { GITHUB_OPTIONS } from '../constants';\nimport { context } from '@actions/github';\nimport { octokit } from '../octokit';\n\ninterface SetDeploymentStatus {\n state: DeploymentState;\n environment: string;\n sha?: string;\n description?: string;\n target_url?: string;\n environment_url?: string;\n}\n\nexport const setDeploymentStatus = ({ sha, state, environment, description, target_url, environment_url }: SetDeploymentStatus) =>\n octokit.repos\n .listDeployments({\n sha,\n environment,\n ...context.repo,\n ...GITHUB_OPTIONS\n })\n .then(deploymentsResponse => {\n const deployment_id = deploymentsResponse.data.find(Boolean)?.id;\n if (deployment_id) {\n return octokit.repos.createDeploymentStatus({\n state,\n deployment_id,\n description,\n target_url,\n environment_url,\n ...context.repo,\n ...GITHUB_OPTIONS\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;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;;;;;;;;;AC9BA;;;;;;;;;;;AAWA;AAGA;AACA;AACA;AAWA,yMAEA;AAEA;AAIA;;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAIA;AACA;;;A;;;;;;;;;;;;;AChDA;;;;;;;;;;;AAWA;AAEA;AAEA;AAEA;;;A;;;A","sourceRoot":""} \ No newline at end of file +{"version":3,"file":"807.index.js","sources":["webpack://github-helpers/./src/constants.ts","webpack://github-helpers/./src/helpers/set-deployment-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 FIRST_QUEUED_PR_LABEL = 'QUEUED FOR MERGE #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)((.*))?: .+$';\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 { DeploymentState } from '../types';\nimport { GITHUB_OPTIONS } from '../constants';\nimport { context } from '@actions/github';\nimport { octokit } from '../octokit';\n\ninterface SetDeploymentStatus {\n state: DeploymentState;\n environment: string;\n sha?: string;\n description?: string;\n target_url?: string;\n environment_url?: string;\n}\n\nexport const setDeploymentStatus = ({ sha, state, environment, description, target_url, environment_url }: SetDeploymentStatus) =>\n octokit.repos\n .listDeployments({\n sha,\n environment,\n ...context.repo,\n ...GITHUB_OPTIONS\n })\n .then(deploymentsResponse => {\n const deployment_id = deploymentsResponse.data.find(Boolean)?.id;\n if (deployment_id) {\n return octokit.repos.createDeploymentStatus({\n state,\n deployment_id,\n description,\n target_url,\n environment_url,\n ...context.repo,\n ...GITHUB_OPTIONS\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;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;;;;;;;;;AC9BA;;;;;;;;;;;AAWA;AAGA;AACA;AACA;AAWA,yMAEA;AAEA;AAIA;;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAIA;AACA;;;A;;;;;;;;;;;;;AChDA;;;;;;;;;;;AAWA;AAEA;AAEA;AAEA;;;A;;;A","sourceRoot":""} \ No newline at end of file diff --git a/dist/905.index.js b/dist/905.index.js index c7ec9697f..a08a4b6b5 100644 --- a/dist/905.index.js +++ b/dist/905.index.js @@ -35,7 +35,7 @@ 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' + 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.'; diff --git a/dist/905.index.js.map b/dist/905.index.js.map index baa58a60e..8ae14fbcc 100644 --- a/dist/905.index.js.map +++ b/dist/905.index.js.map @@ -1 +1 @@ -{"version":3,"file":"905.index.js","sources":["webpack://github-helpers/./src/constants.ts","webpack://github-helpers/./src/helpers/add-labels.ts","webpack://github-helpers/./src/helpers/add-pr-approval-label.ts","webpack://github-helpers/./src/octokit.ts","webpack://github-helpers/./src/utils/get-core-member-logins.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'\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 FIRST_QUEUED_PR_LABEL = 'QUEUED FOR MERGE #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)((.*))?: .+$';\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 { CORE_APPROVED_PR_LABEL, PEER_APPROVED_PR_LABEL } from '../constants';\nimport { addLabels } from './add-labels';\nimport { context } from '@actions/github';\nimport { getCoreMemberLogins } from '../utils/get-core-member-logins';\n\ninterface AddPrApprovalLabel {\n teams: string;\n login: string;\n pull_number: string;\n}\n\nexport const addPrApprovalLabel = async ({ teams, login, pull_number }: AddPrApprovalLabel) => {\n const coreMemberLogins = await getCoreMemberLogins(teams.split('\\n'));\n const approvalLabel = coreMemberLogins.includes(login) ? CORE_APPROVED_PR_LABEL : PEER_APPROVED_PR_LABEL;\n return addLabels({\n labels: approvalLabel,\n pull_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 { 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","/*\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 { map } from 'bluebird';\nimport { octokit } from '../octokit';\nimport { union } from 'lodash';\n\nexport const getCoreMemberLogins = async (teams: string[]) => {\n const adminLogins = await map(teams, team =>\n octokit.teams\n .listMembersInOrg({\n org: context.repo.owner,\n team_slug: team,\n per_page: 100\n })\n .then(listMembersResponse => listMembersResponse.data.map(member => member.login))\n );\n return union(...adminLogins);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;;;;;;;;AC9BA;;;;;;;;;;;AAWA;AAEA;AACA;AAOA;;;A;;;;;;;;;;;;;;;ACrBA;;;;;;;;;;;AAWA;;;;;;;;;;AAEA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AAKA;;;A;;;;;;;;;;;;;AChCA;;;;;;;;;;;AAWA;AAEA;AAEA;AAEA;;;A;;;;;;;;;;;;;;;;ACjBA;;;;;;;;;;;AAWA;;;;;;;;;;AAEA;AACA;AACA;AACA;AAEA;AACA,+LAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;;;A;;;A","sourceRoot":""} \ No newline at end of file +{"version":3,"file":"905.index.js","sources":["webpack://github-helpers/./src/constants.ts","webpack://github-helpers/./src/helpers/add-labels.ts","webpack://github-helpers/./src/helpers/add-pr-approval-label.ts","webpack://github-helpers/./src/octokit.ts","webpack://github-helpers/./src/utils/get-core-member-logins.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 FIRST_QUEUED_PR_LABEL = 'QUEUED FOR MERGE #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)((.*))?: .+$';\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 { CORE_APPROVED_PR_LABEL, PEER_APPROVED_PR_LABEL } from '../constants';\nimport { addLabels } from './add-labels';\nimport { context } from '@actions/github';\nimport { getCoreMemberLogins } from '../utils/get-core-member-logins';\n\ninterface AddPrApprovalLabel {\n teams: string;\n login: string;\n pull_number: string;\n}\n\nexport const addPrApprovalLabel = async ({ teams, login, pull_number }: AddPrApprovalLabel) => {\n const coreMemberLogins = await getCoreMemberLogins(teams.split('\\n'));\n const approvalLabel = coreMemberLogins.includes(login) ? CORE_APPROVED_PR_LABEL : PEER_APPROVED_PR_LABEL;\n return addLabels({\n labels: approvalLabel,\n pull_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 { 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","/*\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 { map } from 'bluebird';\nimport { octokit } from '../octokit';\nimport { union } from 'lodash';\n\nexport const getCoreMemberLogins = async (teams: string[]) => {\n const adminLogins = await map(teams, team =>\n octokit.teams\n .listMembersInOrg({\n org: context.repo.owner,\n team_slug: team,\n per_page: 100\n })\n .then(listMembersResponse => listMembersResponse.data.map(member => member.login))\n );\n return union(...adminLogins);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;;;;;;;;AC9BA;;;;;;;;;;;AAWA;AAEA;AACA;AAOA;;;A;;;;;;;;;;;;;;;ACrBA;;;;;;;;;;;AAWA;;;;;;;;;;AAEA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AAKA;;;A;;;;;;;;;;;;;AChCA;;;;;;;;;;;AAWA;AAEA;AAEA;AAEA;;;A;;;;;;;;;;;;;;;;ACjBA;;;;;;;;;;;AAWA;;;;;;;;;;AAEA;AACA;AACA;AACA;AAEA;AACA,+LAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;;;A;;;A","sourceRoot":""} \ No newline at end of file diff --git a/dist/956.index.js b/dist/956.index.js index 0ada88b24..095dd0000 100644 --- a/dist/956.index.js +++ b/dist/956.index.js @@ -35,7 +35,7 @@ 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' + 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.'; diff --git a/dist/956.index.js.map b/dist/956.index.js.map index 6fa456f4d..4e5934866 100644 --- a/dist/956.index.js.map +++ b/dist/956.index.js.map @@ -1 +1 @@ -{"version":3,"file":"956.index.js","sources":["webpack://github-helpers/./src/constants.ts","webpack://github-helpers/./src/helpers/check-pr-title.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'\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 FIRST_QUEUED_PR_LABEL = 'QUEUED FOR MERGE #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)((.*))?: .+$';\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 { DEFAULT_PR_TITLE_REGEX } from '../constants';\nimport { context } from '@actions/github';\nimport { octokit } from '../octokit';\nimport { setFailed } from '@actions/core';\n\ninterface CheckPrTitle {\n pull_number: string;\n pattern?: string;\n}\n\nexport const checkPrTitle = ({ pull_number, pattern = DEFAULT_PR_TITLE_REGEX }: CheckPrTitle) => {\n const regex = new RegExp(pattern);\n return octokit.pulls\n .get({\n pull_number: Number(pull_number),\n ...context.repo\n })\n .then(prResponse => {\n if (regex.test(prResponse.data.title)) {\n return true;\n }\n setFailed('Pull request title does not meet requirements.');\n return false;\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;;;A;;;;;;;;;;;;;;;;AC9BA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AACA;AAOA;AACA;AACA,qFACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;;;;;;;;ACrCA;;;;;;;;;;;AAWA;AAEA;AAEA;AAEA;;;A;;;A","sourceRoot":""} \ No newline at end of file +{"version":3,"file":"956.index.js","sources":["webpack://github-helpers/./src/constants.ts","webpack://github-helpers/./src/helpers/check-pr-title.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 FIRST_QUEUED_PR_LABEL = 'QUEUED FOR MERGE #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)((.*))?: .+$';\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 { DEFAULT_PR_TITLE_REGEX } from '../constants';\nimport { context } from '@actions/github';\nimport { octokit } from '../octokit';\nimport { setFailed } from '@actions/core';\n\ninterface CheckPrTitle {\n pull_number: string;\n pattern?: string;\n}\n\nexport const checkPrTitle = ({ pull_number, pattern = DEFAULT_PR_TITLE_REGEX }: CheckPrTitle) => {\n const regex = new RegExp(pattern);\n return octokit.pulls\n .get({\n pull_number: Number(pull_number),\n ...context.repo\n })\n .then(prResponse => {\n if (regex.test(prResponse.data.title)) {\n return true;\n }\n setFailed('Pull request title does not meet requirements.');\n return false;\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;;;A;;;;;;;;;;;;;;;;AC9BA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AACA;AAOA;AACA;AACA,qFACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;;;;;;;;ACrCA;;;;;;;;;;;AAWA;AAEA;AAEA;AAEA;;;A;;;A","sourceRoot":""} \ No newline at end of file diff --git a/src/constants.ts b/src/constants.ts index d32f58153..bffb36e3a 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -14,7 +14,7 @@ limitations under the License. // These extra headers are for experimental operations. Newer versions of octokit may not require this export const GITHUB_OPTIONS = { headers: { - accept: 'application/vnd.github.ant-man-preview+json,application/vnd.github.flash-preview+json' + accept: 'application/vnd.github.ant-man-preview+json,application/vnd.github.flash-preview+json,application/vnd.github.v3+json' } };