Convert a GitHub repo to a Cookiecutter template
Last updated
Was this helpful?
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.pyClone 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":"author@example.com",
"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:
In each of the files and folders, replace existing fields with the corresponding Cookiecutter fields.
For example, a Dockerfile may include the line MAINTAINER author@example.com. This can be changed to the following:
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.
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?
Was this helpful?
/{{cookiecutter.project_name}}
|- Dockerfile
|- ReadMe
|- pipeline.yaml
|- App
|- App.py
cookiecutter.jsonMAINTAINER {{cookiecutter.author}}