Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ jobs:
- `alias: deploy-preview-${{ github.event.number }}` replicates the [deploy preview prefix](https://docs.netlify.com/site-deploys/overview/#definitions)
- `github-deployment-environment` Environment name of GitHub Deployments
- `github-deployment-description` Description of the GitHub Deployment
- `fails-without-credentials` Fails if no credentials provided (default: false)

### Paths are relative to the project's root
All paths (eg, `publish-dir`, `netlify-config-path`, `functions-dir`) are relative to the project's root or absolute paths.
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ inputs:
github-deployment-description:
description: Description of the GitHub Deployment
required: false
fails-without-credentials:
description: Fails if no credentials provided
required: false
outputs:
deploy-url:
description: Deploy URL
Expand Down
10 changes: 9 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ exports.defaultInputs = {
},
githubDeploymentDescription() {
return core.getInput('github-deployment-description') || undefined;
},
failsWithoutCredentials() {
// Default: false
return core.getInput('fails-without-credentials') === 'true';
}
};

Expand Down Expand Up @@ -194,7 +198,11 @@ function run(inputs) {
const siteId = process.env.NETLIFY_SITE_ID;
// NOTE: Non-collaborators PRs don't pass GitHub secrets to GitHub Actions.
if (!(netlifyAuthToken && siteId)) {
process.stderr.write('Netlify credentials not provided, not deployable');
const errorMessage = 'Netlify credentials not provided, not deployable';
if (inputs.failsWithoutCredentials()) {
throw new Error(errorMessage);
}
process.stderr.write(errorMessage);
return;
}
const dir = inputs.publishDir();
Expand Down
5 changes: 5 additions & 0 deletions src/inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface Inputs {
alias(): string | undefined
githubDeploymentEnvironment(): string | undefined
githubDeploymentDescription(): string | undefined
failsWithoutCredentials(): boolean
}

export const defaultInputs: Inputs = {
Expand Down Expand Up @@ -67,5 +68,9 @@ export const defaultInputs: Inputs = {
},
githubDeploymentDescription(): string | undefined {
return core.getInput('github-deployment-description') || undefined
},
failsWithoutCredentials(): boolean {
// Default: false
return core.getInput('fails-without-credentials') === 'true'
}
}
6 changes: 5 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ export async function run(inputs: Inputs): Promise<void> {
const siteId = process.env.NETLIFY_SITE_ID
// NOTE: Non-collaborators PRs don't pass GitHub secrets to GitHub Actions.
if (!(netlifyAuthToken && siteId)) {
process.stderr.write('Netlify credentials not provided, not deployable')
const errorMessage = 'Netlify credentials not provided, not deployable'
if (inputs.failsWithoutCredentials()) {
throw new Error(errorMessage)
}
process.stderr.write(errorMessage)
return
}
const dir = inputs.publishDir()
Expand Down