diff --git a/src/command/publish/deployment.ts b/src/command/publish/deployment.ts index 57a66af8586..524cd51cc7c 100644 --- a/src/command/publish/deployment.ts +++ b/src/command/publish/deployment.ts @@ -26,6 +26,7 @@ import { publishRecordIdentifier, readAccountsPublishedTo, } from "../../publish/common/data.ts"; +import { kGhpages } from "../../publish/gh-pages/gh-pages.ts"; export async function resolveDeployment( options: PublishOptions, @@ -84,7 +85,7 @@ export async function resolveDeployment( } } else { return await chooseDeployment(deployments); - } + } } else if (deployments.length === 1) { return deployments[0]; } else { @@ -95,7 +96,12 @@ export async function resolveDeployment( } else if (!options.prompt) { // if we get this far then an existing deployment has not been chosen, // if --no-prompt is specified then this is an error state - if (!options.prompt) { + if (providerFilter === kGhpages) { + // special case for gh-pages where no _publish.yml is required but a gh-pages branch is + throw new Error( + `Unable to publish to GitHub Pages (the remote origin does not have a branch named "gh-pages". Use first \`quarto publish gh-pages\` locally to initialize the remote repository for publishing.)`, + ); + } else { throw new Error( `No _publish.yml file available (_publish.yml specifying a destination required for non-interactive publish)`, ); diff --git a/src/publish/gh-pages/gh-pages.ts b/src/publish/gh-pages/gh-pages.ts index 2907ac58d4e..68e557d3ad8 100644 --- a/src/publish/gh-pages/gh-pages.ts +++ b/src/publish/gh-pages/gh-pages.ts @@ -96,10 +96,6 @@ async function publishRecord( id: "gh-pages", url: ghContext.siteUrl || ghContext.originUrl, }; - } else { - throwUnableToPublish( - 'the remote origin does not have a branch named "gh-pages". Use first `quarto publish gh-pages` locally to initialize the remote repository for publishing.', - ); } }