From b9415707f9e8c4e4ef6ef81b4ebb874f05a93861 Mon Sep 17 00:00:00 2001 From: yimysty Date: Wed, 22 Sep 2021 17:27:15 -0700 Subject: [PATCH] add pages deployment step --- dist/index.js | 32 ++++++++++++++++++++++---------- src/upload-artifact.ts | 32 ++++++++++++++++++++++---------- 2 files changed, 44 insertions(+), 20 deletions(-) diff --git a/dist/index.js b/dist/index.js index 5a201a0..d789d0b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -5542,17 +5542,29 @@ function run() { } else { core.info(`Artifact ${uploadResponse.artifactName} has been successfully uploaded!`); + let runtimeUrl = process.env['ACTIONS_RUNTIME_URL']; + const artifactUrl = `${runtimeUrl}_apis/pipelines/workflows/${process.env['GITHUB_RUN_ID']}/artifacts?api-version=6.0-preview`; + let response = yield axios_1.default.get(artifactUrl, { + headers: { + "Authorization": `Bearer ${process.env["ACTIONS_RUNTIME_TOKEN"]}`, + "Content-Type": "application/json" + } + }); + const unsignedUrl = response.data.value[0].url; + console.log(response); + console.log(`unsigned artifact url is ${unsignedUrl}`); + response = yield axios_1.default.post("api.github.com/repos/github/hub/pages/deployment", { + artifact_url: unsignedUrl, + pages_build_version: process.env['GITHUB_SHA'] + }, { + headers: { + "Accept": "application/vnd.github.v3+json", + "Content-Type": "application/json", + "Authorization": `Bearer ${process.env['GITHUB_TOKEN']}` + } + }); + console.log(response.data); } - let runtimeUrl = process.env['ACTIONS_RUNTIME_URL']; - console.log(runtimeUrl); - const artifactUrl = `${runtimeUrl}_apis/pipelines/workflows/${process.env['GITHUB_RUN_ID']}/artifacts?api-version=6.0-preview`; - const response = yield axios_1.default.get(artifactUrl, { - headers: { - "Authorization": `Bearer ${process.env["ACTIONS_RUNTIME_TOKEN"]}`, - "Content-Type": "application/json" - } - }); - console.log(response.data); } } catch (err) { diff --git a/src/upload-artifact.ts b/src/upload-artifact.ts index 07cdfb8..1c67483 100644 --- a/src/upload-artifact.ts +++ b/src/upload-artifact.ts @@ -67,17 +67,29 @@ async function run(): Promise { core.info( `Artifact ${uploadResponse.artifactName} has been successfully uploaded!` ) + let runtimeUrl = process.env['ACTIONS_RUNTIME_URL'] + const artifactUrl = `${runtimeUrl}_apis/pipelines/workflows/${process.env['GITHUB_RUN_ID']}/artifacts?api-version=6.0-preview`; + let response = await axios.get(artifactUrl, { + headers:{ + "Authorization": `Bearer ${process.env["ACTIONS_RUNTIME_TOKEN"]}`, + "Content-Type": "application/json" + } + }); + const unsignedUrl = response.data.value[0].url + console.log(response) + console.log(`unsigned artifact url is ${unsignedUrl}`) + response = await axios.post("api.github.com/repos/github/hub/pages/deployment", { + artifact_url: unsignedUrl, + pages_build_version: process.env['GITHUB_SHA'] + }, { + headers: { + "Accept": "application/vnd.github.v3+json", + "Content-Type": "application/json", + "Authorization": `Bearer ${process.env['GITHUB_TOKEN']}` + } + }) + console.log(response.data) } - let runtimeUrl = process.env['ACTIONS_RUNTIME_URL'] - console.log(runtimeUrl) - const artifactUrl = `${runtimeUrl}_apis/pipelines/workflows/${process.env['GITHUB_RUN_ID']}/artifacts?api-version=6.0-preview`; - const response = await axios.get(artifactUrl, { - headers:{ - "Authorization": `Bearer ${process.env["ACTIONS_RUNTIME_TOKEN"]}`, - "Content-Type": "application/json" - } - }); - console.log(response.data) } } catch (err) { core.setFailed(err.message)