Skip to content
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
12 changes: 12 additions & 0 deletions packages/cli/src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ export interface PrecisaManifest {
*/
siteProjectName?: string;

/**
* Path prefix (relative to repo root, trailing slash) treated as site
* source for change detection in `_deploy-site.yml`. Defaults to
* `site/` — override to `packages/site/` for monorepos where the site
* lives under `packages/`.
*/
siteSourcePath?: string;

/** Public-OSS or private-internal. Controls which templates are rendered. */
visibility: 'oss' | 'private';
}
Expand Down Expand Up @@ -134,6 +142,7 @@ export function tokenContext(manifest: PrecisaManifest): Record<string, string>
SECURITY_EMAIL: manifest.contactEmails.security,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding checks for valid values of siteSourcePath to prevent unintended paths from being used.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already covered: siteSourcePath passa por validateManifest() (tem que ser string quando presente) e tem default 'site/' que cobre o layout classico. Paths invalidos falham explicitamente no proprio _deploy-site.yml (compareCommitsWithBasehead nao quebra por prefix que nao match — so retorna site_changed: false). Over-validacao aqui e overengineering pro benefício marginal.

SITE_FILTER: manifest.siteFilter ?? '',
SITE_PROJECT_NAME: manifest.siteProjectName ?? '',
SITE_SOURCE_PATH: manifest.siteSourcePath ?? 'site/',
VISIBILITY: manifest.visibility,
};
}
Expand Down Expand Up @@ -197,6 +206,9 @@ export function validateManifest(raw: unknown): ManifestValidationError[] {
if (m.siteFilter !== undefined && typeof m.siteFilter !== 'string') {
errors.push({ message: 'must be a string', path: 'siteFilter' });
}
if (m.siteSourcePath !== undefined && typeof m.siteSourcePath !== 'string') {
errors.push({ message: 'must be a string', path: 'siteSourcePath' });
}
if (!m.contactEmails || typeof m.contactEmails !== 'object') {
errors.push({ message: 'must be an object', path: 'contactEmails' });
} else {
Expand Down
7 changes: 6 additions & 1 deletion templates/github/workflows/_deploy-site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ on:
description: 'Output directory to deploy (default: site/dist)'
type: string
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that the new input site_source_path is properly validated and handled in the workflow to avoid misconfigurations.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already covered: siteSourcePath passa por validateManifest() (tem que ser string quando presente) e tem default 'site/' que cobre o layout classico. Paths invalidos falham explicitamente no proprio _deploy-site.yml (compareCommitsWithBasehead nao quebra por prefix que nao match — so retorna site_changed: false). Over-validacao aqui e overengineering pro benefício marginal.

default: 'site/dist'
site_source_path:
description: 'Path prefix treated as site source files for change detection (default: site/)'
type: string
default: 'site/'

jobs:
build-site:
Expand Down Expand Up @@ -57,7 +61,8 @@ jobs:
);
filenames = pages.flatMap(p => (p.files ?? []).map(f => f.filename));
}
const siteChanged = filenames.some(f => f.startsWith('site/'));
const sourcePath = `${{ inputs.site_source_path }}`;
const siteChanged = filenames.some(f => f.startsWith(sourcePath));
core.setOutput('site_changed', siteChanged ? 'true' : 'false');

- uses: actions/checkout@v6
Expand Down
1 change: 1 addition & 0 deletions templates/github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,6 @@ jobs:
with:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double-check that the new SITE_SOURCE_PATH variable correctly maps to the expected input in workflows that depend on site file paths to prevent potential site deployment issues.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already covered: siteSourcePath passa por validateManifest() (tem que ser string quando presente) e tem default 'site/' que cobre o layout classico. Paths invalidos falham explicitamente no proprio _deploy-site.yml (compareCommitsWithBasehead nao quebra por prefix que nao match — so retorna site_changed: false). Over-validacao aqui e overengineering pro benefício marginal.

project_name: '{{SITE_PROJECT_NAME}}'
site_filter: '{{SITE_FILTER}}'
site_source_path: '{{SITE_SOURCE_PATH}}'
secrets: inherit
# {{/if}}
Loading