Convert a GitHub repo to a Cookiecutter template
If you are using GitHub templates to standardize your service creation, it is possible to convert the templates for use within a Cortex Workflow.
This guide explains how to convert a GitHub repository template into a Cookiecutter template, enabling a more efficient process when you scaffold the repository from a Workflow.
In this guide, assume the repository has the following structure:
Dockerfile
ReadMe
pipeline.yaml
/App
|- App.py
How to convert a GitHub template to a Cookiecutter template
Clone the existing GitHub repository locally.
Create a cookiecutter.json file, including the basic inputs needed from the user, other fields that will be used in the template, and the version (required). For example:
{
"project_name":"my project",
"author":"[email protected]",
"version": 0.1.0
}
Create a base folder with a name similar to:
{{ cookiecutter.project_name }}
Move the contents of the repo into to folder you created in Step 3. For example:
/{{cookiecutter.project_name}}
|- Dockerfile
|- ReadMe
|- pipeline.yaml
|- App
|- App.py
cookiecutter.json
In each of the files and folders, replace existing fields with the corresponding Cookiecutter fields.
For example, a Dockerfile may include the line
MAINTAINER [email protected]
. This can be changed to the following:
MAINTAINER {{cookiecutter.author}}
Optionally, add content to the README in the repository to document what the Cookiecutter template does.
When registering a Scaffolder template, you can choose whether to display the README in Cortex when running a Scaffolder block in a Workflow.
Handling existing mustache templating in a repository file
You may have files that already contain mustache templating. In an instance where you do not want these interpreted as Cookiecutter fields, you can escape the curly braces, as described in Cookiecutter's troubleshooting docs here.
Last updated
Was this helpful?