From 6700dcbb70f4aa2307e35cad5fb1f494c5eb346f Mon Sep 17 00:00:00 2001 From: Emmanuel Raviart <emmanuel@raviart.com> Date: Thu, 28 Oct 2021 17:22:11 +0200 Subject: [PATCH] Add triggering of prod deployment. --- gitlab-ci/src/gitlab-ci.ts | 54 +++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/gitlab-ci/src/gitlab-ci.ts b/gitlab-ci/src/gitlab-ci.ts index 29b346d0c..6831370a8 100644 --- a/gitlab-ci/src/gitlab-ci.ts +++ b/gitlab-ci/src/gitlab-ci.ts @@ -206,11 +206,11 @@ async function main() { ) await commitAndPushWithUpdatedVersions(nextVersionObject) await triggerDevDeployPipeline() - // await triggerProdDeployPipeline(); + await triggerProdDeployPipeline() } await triggerDevDeployPipeline() - // await triggerProdDeployPipeline() + await triggerProdDeployPipeline() } else { console.log( `Unhandled event "${CI_PIPELINE_SOURCE}" in branch "${CI_COMMIT_BRANCH}".`, @@ -383,31 +383,31 @@ async function triggerDevDeployPipeline() { ) } -// async function triggerProdDeployPipeline() { -// const url = new URL( -// `/api/v4/projects/29/trigger/pipeline`, -// CI_SERVER_URL -// ).toString(); -// console.log( -// "Triggering LexImpact socio-fiscal Prod Deploy pipeline on master branch…" -// ); -// const response = await fetch(url, { -// body: new URLSearchParams({ -// ref: "master", -// token: CI_JOB_TOKEN!, -// }).toString(), -// headers: { -// "Content-Type": "application/x-www-form-urlencoded", -// }, -// method: "POST", -// }); -// assert( -// response.ok, -// `Unexpected response from ${url}: ${response.status} ${ -// response.statusText -// }\n${await response.text()}` -// ); -// } +async function triggerProdDeployPipeline() { + const url = new URL( + `/api/v4/projects/29/trigger/pipeline`, + CI_SERVER_URL, + ).toString() + console.log( + "Triggering LexImpact socio-fiscal Prod Deploy pipeline on master branch…", + ) + const response = await fetch(url, { + body: new URLSearchParams({ + ref: "master", + token: CI_JOB_TOKEN!, + }).toString(), + headers: { + "Content-Type": "application/x-www-form-urlencoded", + }, + method: "POST", + }) + assert( + response.ok, + `Unexpected response from ${url}: ${response.status} ${ + response.statusText + }\n${await response.text()}`, + ) +} function versionFromObject({ major, minor, patch }: VersionObject): string { return `${major}.${minor}.${patch}` -- GitLab