diff --git a/src/bin/vip-app-deploy.ts b/src/bin/vip-app-deploy.ts index f1b4ea5ebd..7284eb0a8d 100755 --- a/src/bin/vip-app-deploy.ts +++ b/src/bin/vip-app-deploy.ts @@ -30,8 +30,6 @@ import { } from '../lib/custom-deploy/custom-deploy'; import { trackEventWithEnv } from '../lib/tracker'; -const CUSTOM_DEPLOY_KEY = process.env.CUSTOM_DEPLOY_KEY || ''; - const appQuery = ` id, name, @@ -129,10 +127,8 @@ export async function appDeployCmd( arg: string[] = [], opts: Record< string, un exit.withError( 'The type of application you specified does not currently support deploys.' ); } - if ( CUSTOM_DEPLOY_KEY ) { - debug( 'Validating custom deploy key...' ); - await validateCustomDeployKey( CUSTOM_DEPLOY_KEY, envId ); - } + debug( 'Validating custom deploy key if present...' ); + await validateCustomDeployKey( envId ); await validateFile( app, env, fileMeta ); diff --git a/src/lib/custom-deploy/custom-deploy.ts b/src/lib/custom-deploy/custom-deploy.ts index 2460aa72c9..990ae006f0 100644 --- a/src/lib/custom-deploy/custom-deploy.ts +++ b/src/lib/custom-deploy/custom-deploy.ts @@ -11,16 +11,14 @@ import { trackEventWithEnv } from '../../lib/tracker'; import { validateDeployFileExt, validateFilename } from '../../lib/validations/custom-deploy'; const DEPLOY_MAX_FILE_SIZE = 4 * GB_IN_BYTES; +const CUSTOM_DEPLOY_KEY = process.env.CUSTOM_DEPLOY_KEY; export function isSupportedApp( app: App ): boolean { return WORDPRESS_SITE_TYPE_IDS.includes( app.typeId as number ); } -export async function validateCustomDeployKey( - customDeployKey: string, - envId: number -): Promise< void > { - if ( customDeployKey.length === 0 ) { +export async function validateCustomDeployKey( envId: number ): Promise< void > { + if ( ! CUSTOM_DEPLOY_KEY || CUSTOM_DEPLOY_KEY.length === 0 ) { exit.withError( 'Valid custom deploy key is required.' ); } @@ -32,7 +30,7 @@ export async function validateCustomDeployKey( } `; - const api = await API( { customAuthToken: customDeployKey } ); + const api = await API( { customAuthToken: CUSTOM_DEPLOY_KEY } ); try { await api.mutate( { mutation: VALIDATE_CUSTOM_DEPLOY_ACCESS_MUTATION } ); } catch ( error ) {