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

feat: adds support for x-vercel-protection-bypass #68

Merged
Merged
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ Optional - How often (in seconds) should we make the HTTP request checking to se

Optional - The [password](https://vercel.com/docs/concepts/projects/overview#password-protection) for the deployment

### `vercel_protection_bypass_header`

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

### `path`

Optional - The URL that tests should run against (eg. `path: "https://vercel.com"`).
Expand Down
9 changes: 9 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,
protectionBypassHeader,
path,
}) => {
const iterations = calculateIterations(
Expand All @@ -39,6 +40,12 @@ const waitForUrl = async ({
core.setOutput('vercel_jwt', jwt);
}

if (protectionBypassHeader) {
headers = {
'x-vercel-protection-bypass': protectionBypassHeader
};
}

let checkUri = new URL(path, url);

await axios.get(checkUri.toString(), {
Expand Down Expand Up @@ -280,6 +287,7 @@ const run = async () => {
// Inputs
const GITHUB_TOKEN = core.getInput('token', { required: true });
const VERCEL_PASSWORD = core.getInput('vercel_password');
const VERCEL_PROTECTION_BYPASS_HEADER = core.getInput('vercel_protection_bypass_header');
const ENVIRONMENT = core.getInput('environment');
const MAX_TIMEOUT = Number(core.getInput('max_timeout')) || 60;
const ALLOW_INACTIVE = Boolean(core.getInput('allow_inactive')) || false;
Expand Down Expand Up @@ -367,6 +375,7 @@ const run = async () => {
maxTimeout: MAX_TIMEOUT,
checkIntervalInMilliseconds: CHECK_INTERVAL_IN_MS,
vercelPassword: VERCEL_PASSWORD,
protectionBypassHeader: VERCEL_PROTECTION_BYPASS_HEADER,
path: PATH,
});
} catch (error) {
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ inputs:
vercel_password:
description: 'Vercel password protection secret'
required: false
vercel_protection_bypass_header:
description: 'Vercel protection bypass for automation'
required: false
path:
description: 'The path to check. Defaults to the index of the domain'
default: '/'
Expand Down