From 7ccf91c9ba3d64aa4389c0d3adcba0a6e77e5421 Mon Sep 17 00:00:00 2001 From: Jawakar <31589372+jawakarD@users.noreply.github.com> Date: Wed, 10 Nov 2021 03:58:34 +0530 Subject: [PATCH] Feature: Add base path (#16) * Add base path to test which defaults to / * Add base_path to readme --- README.md | 4 ++++ action.yml | 4 ++++ index.js | 3 ++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c67a1a52..35f83656 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,10 @@ Optional — Stringified HTTP Header object key/value pairs to send in requests Optional — The amount of time to spend waiting on Netlify. Defaults to `60` seconds +### `base_path` + +Optional — The page that needs to be tested for 200. Defaults to "/" (eg: `https://{site_name}.netlify.app{base_path}`) + ## Outputs ### `url` diff --git a/action.yml b/action.yml index 1742fe36..574db2cf 100644 --- a/action.yml +++ b/action.yml @@ -13,6 +13,10 @@ inputs: max_timeout: description: "The max time to run the action" required: false + base_path: + description: "Base path to test" + required: false + default: "/" outputs: url: description: "The fully qualified deploy preview URL" diff --git a/index.js b/index.js index 0de17805..d5c5c4b8 100644 --- a/index.js +++ b/index.js @@ -26,10 +26,11 @@ const run = async () => { } const MAX_TIMEOUT = Number(core.getInput("max_timeout")) || 60; const siteName = core.getInput("site_name"); + const basePath = core.getInput("base_path"); if (!siteName) { core.setFailed("Required field `site_name` was not provided"); } - const url = `https://deploy-preview-${PR_NUMBER}--${siteName}.netlify.app`; + const url = `https://deploy-preview-${PR_NUMBER}--${siteName}.netlify.app${basePath}`; core.setOutput("url", url); const extraHeaders = core.getInput("request_headers"); const headers = !extraHeaders ? {} : JSON.parse(extraHeaders)