mirror of
https://github.com/tauri-apps/actions-netlify.git
synced 2026-01-31 00:45:22 +01:00
add input fails-without-credentials (#532)
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
10
dist/index.js
vendored
10
dist/index.js
vendored
@@ -83,6 +83,10 @@ exports.defaultInputs = {
|
||||
},
|
||||
githubDeploymentDescription() {
|
||||
return core.getInput('github-deployment-description') || undefined;
|
||||
},
|
||||
failsWithoutCredentials() {
|
||||
// Default: false
|
||||
return core.getInput('fails-without-credentials') === 'true';
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -16,6 +16,7 @@ export interface Inputs {
|
||||
alias(): string | undefined
|
||||
githubDeploymentEnvironment(): string | undefined
|
||||
githubDeploymentDescription(): string | undefined
|
||||
failsWithoutCredentials(): boolean
|
||||
}
|
||||
|
||||
export const defaultInputs: Inputs = {
|
||||
@@ -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'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user