diff --git a/action.yml b/action.yml index 4d2fe7c..0ba7e9d 100644 --- a/action.yml +++ b/action.yml @@ -10,4 +10,10 @@ inputs: required: true outputs: base_url: - description: 'URL to deployed GitHub Pages' + description: 'GitHub Pages site full base URL. Examples: "https://octocat.github.io/my-repo/", "https://octocat.github.io/", "https://www.example.com/"' + origin: + description: 'GitHub Pages site origin. Examples: "https://octocat.github.io", "https://www.example.com"' + host: + description: 'GitHub Pages site host. Examples: "octocat.github.io", "www.example.com"' + base_path: + description: 'GitHub Pages site full base path. Examples: "/my-repo/" or "/"' diff --git a/src/index.js b/src/index.js index 4b3ad85..2a9e3a7 100644 --- a/src/index.js +++ b/src/index.js @@ -12,6 +12,7 @@ async function getPageBaseUrl() { core.info("GITHUB_TOKEN : " + context.githubToken) + core.info(`Get the Base URL to the page with endpoint ${pagesEndpoint}`) const response = await axios.get( pagesEndpoint, { @@ -24,8 +25,12 @@ async function getPageBaseUrl() { 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}`) + + const siteUrl = new URL(pageObject.html_url) + core.setOutput('base_url', siteUrl.href) + core.setOutput('origin', siteUrl.origin) + core.setOutput('host', siteUrl.host) + core.setOutput('base_path', siteUrl.pathname) } catch (e) { console.info('Get on the Page failed', e) process.exit(1)