From 43f9924230514efc693eec69298c48fea458bf9f Mon Sep 17 00:00:00 2001 From: Smitha Borkar <12040799+smithaborkar@users.noreply.github.com> Date: Tue, 7 Jun 2022 11:59:57 -0700 Subject: [PATCH] Update index.js --- src/index.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/index.js b/src/index.js index 8b13789..2d04803 100644 --- a/src/index.js +++ b/src/index.js @@ -1 +1,31 @@ +const core = require('@actions/core') +const axios = require('axios') + + +async function getPageBaseUrl(evtOrExitCodeOrError) { + try { + if (deployment.requestedDeployment) { + const pagesEndpoint = `https://api.github.com/repos/${process.env.GITHUB_REPOSITORY}/pages` + const response = await axios.get( + pagesEndpoint, + {}, + { + headers: { + Accept: 'application/vnd.github.v3+json', + Authorization: `Bearer ${process.env.GITHUB_TOKEN}`, + 'Content-type': 'application/json' + } + } + ) + + pageObject = response.data + core.info(JSON.stringify(pageObject)) + core.setOutput('base_url', pageObject.html_url) + core.info(`Get the Base URL to the page with endpoint ${pagesEndpoint}`) + } + } catch (e) { + console.info('Get on the Page failed', e) + } + process.exit(isNaN(+evtOrExitCodeOrError) ? 1 : +evtOrExitCodeOrError) +}