Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Basic Auth and Skip Health Check Option #69

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ Optional - The [password](https://vercel.com/docs/concepts/projects/overview#pas

Optional - The [header](https://vercel.com/docs/security/deployment-protection/methods-to-bypass-deployment-protection/protection-bypass-automation) to bypass protection for automation

### `basic_auth_credentials_base64`

Optional - Use if your app is protected with basic auth. provide your base64 encoded credentials in form `username:password`, see [basic auth](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authorization#basic_authentication)

### `skip_health_check``
Optional - Skip the health check for status code 200 and return the URL immediately after successful deployment. Defaults to `false`.

### `path`

Optional - The URL that tests should run against (eg. `path: "https://vercel.com"`).
Expand Down
15 changes: 15 additions & 0 deletions action.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const waitForUrl = async ({
maxTimeout,
checkIntervalInMilliseconds,
vercelPassword,
basicAuthCredentials,
protectionBypassHeader,
path,
}) => {
Expand Down Expand Up @@ -46,6 +47,12 @@ const waitForUrl = async ({
};
}

if (basicAuthCredentials) {
headers = {
'Authorization': `Basic ${basicAuthCredentials}`
};
}

let checkUri = new URL(path, url);

await axios.get(checkUri.toString(), {
Expand Down Expand Up @@ -289,6 +296,8 @@ const run = async () => {
const VERCEL_PASSWORD = core.getInput('vercel_password');
const VERCEL_PROTECTION_BYPASS_HEADER = core.getInput('vercel_protection_bypass_header');
const ENVIRONMENT = core.getInput('environment');
const BASIC_AUTH_CREDENTIALS_BASE_64 = core.getInput('basic_auth_credentials_base64');
const SKIP_HEALTH_CHECK = core.getInput('skip_health_check') === 'true';
const MAX_TIMEOUT = Number(core.getInput('max_timeout')) || 60;
const ALLOW_INACTIVE = Boolean(core.getInput('allow_inactive')) || false;
const PATH = core.getInput('path') || '/';
Expand Down Expand Up @@ -367,6 +376,11 @@ const run = async () => {
// Set output
core.setOutput('url', targetUrl);

if (SKIP_HEALTH_CHECK) {
console.log('Skipping health check');
return;
}

// Wait for url to respond with a success
console.log(`Waiting for a status code 200 from: ${targetUrl}`);

Expand All @@ -376,6 +390,7 @@ const run = async () => {
checkIntervalInMilliseconds: CHECK_INTERVAL_IN_MS,
vercelPassword: VERCEL_PASSWORD,
protectionBypassHeader: VERCEL_PROTECTION_BYPASS_HEADER,
basicAuthCredentials: BASIC_AUTH_CREDENTIALS_BASE_64,
path: PATH,
});
} catch (error) {
Expand Down
7 changes: 7 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ inputs:
vercel_protection_bypass_header:
description: 'Vercel protection bypass for automation'
required: false
basic_auth_credentials_base64:
description: 'In case the app is protected with Basic Auth, provide base64 encoded credentials in form `username:password`'
required: false
skip_health_check:
default: 'false'
description: 'Skip health check for status code 200 after deployment'
required: false
path:
description: 'The path to check. Defaults to the index of the domain'
default: '/'
Expand Down
Loading