templates

templates

Workflow template files for syncweaver.

Templates can be listed and copied into downstream host repository or package repos using the helper functions below or via the CLI:

syncweaver templates list
syncweaver templates add syncweaver-update-source --output .github/workflows/
syncweaver templates add syncweaver-notify-host-update-source --output .github/workflows/

Use available_templates_markdown() to render the current template inventory.

Functions

Name Description
available_templates_markdown Build a markdown bullet list of currently available template files.
list_templates List available workflow templates.
read_template Read a template file’s contents.
use_template Copy a workflow template into the specified output directory.

available_templates_markdown

templates.available_templates_markdown()

Build a markdown bullet list of currently available template files.

Returns

Name Type Description
str str Markdown-formatted bullet list.

Examples

>>> available_templates_markdown()

list_templates

templates.list_templates()

List available workflow templates.

Returns

Name Type Description
list[str] list[str]: Template file names.

Examples

>>> list_templates()

read_template

templates.read_template(template_name)

Read a template file’s contents.

Parameters

Name Type Description Default
template_name str Name of the template file (with or without .yml extension). required

Returns

Name Type Description
str str Contents of the template file.

Raises

Name Type Description
FileNotFoundError If the template file does not exist.

Examples

>>> read_template("host-repo-pattern1-outbound.yml")

use_template

templates.use_template(
    template_name,
    output_dir='.github/workflows',
    overwrite=False,
)

Copy a workflow template into the specified output directory.

Parameters

Name Type Description Default
template_name str Name of the template file (with or without .yml extension). required
output_dir str | pathlib.Path Directory to write the template. Defaults to .github/workflows. '.github/workflows'
overwrite bool If True, overwrite an existing file. Defaults to False. False

Returns

Name Type Description
pathlib.Path pathlib.Path: Path to the written file.

Raises

Name Type Description
FileNotFoundError If the template does not exist.
FileExistsError If the destination file already exists and overwrite is False.

Examples

>>> use_template("host-repo-pattern1-outbound.yml")