Skip to content
layers

GitHub Action

Cookiecutter in Github Actions

v1.3.2 Latest version

Cookiecutter in Github Actions

layers

Cookiecutter in Github Actions

Generate from a cookiecutter template as part of your github workflow

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Cookiecutter in Github Actions

uses: andrewthetechie/[email protected]

Learn more about this action in andrewthetechie/gha-cookiecutter

Choose a version

Cookiecutter in GHA

Action Template Actions Status Actions Status

Description

Generate from a cookiecutter template as part of your github workflow

Usage

Runs cookiecutter on the specified template, passing in the values input as cookiecutterValues.

This action does not commit or push any files, check out an action like stefanzweifel/git-auto-commit-action for a way to commit generated files.

Example workflow

name: Run Cookiecutter
on: [workflow_dispatch]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - name: Run Cookiecutter
      uses: andrewthetechie/gha-cookiecutter@main
      with:
        # can be a link to a git repo or a local path
        template: https://github.com/cjolowicz/cookiecutter-hypermodern-python
        cookiecutterValues: '{
           "foo": "bar",
           "baz": "boo",
           "num": 2
         }'

Or to use a cookiecutter in a private repo, use a checkout with a token that has access to that repo

name: Run Cookiecutter Private
on: [workflow_dispatch]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
      with:
        repository: "yourprivatecookiecutter"
        token: ${{ secrets.GITHUB_TOKEN }}
    - name: Run Cookiecutter
      uses: andrewthetechie/gha-cookiecutter@main
      with:
        # path to what you checked out
        template: ./yourprivatecookiecutter
        cookiecutterValues: '{
           "foo": "bar",
           "baz": "boo",
           "num": 2
         }'

Inputs

parameter description required default
cookiecutterValues Json blob to pass to the cookiecutter template. Any values not filled in will be set to template's default false {}
template A directory containing a project template directory (or zip file), or a URL to a git repository. true
templateCheckout The branch, tag or commit ID to checkout after clone. false
templateDirectory Relative path to a cookiecutter template in a repository. false
outputDir Where to output the generated project dir into. false .
overwrite Overwrite files if they already exist in outputDir if true. Takes priority over 'skip' false false
skip Skip files if they already exist in outputDir if true. Ignored if 'overwrite' is true false false
zipPassword If your template zip is password protected, put your password here false
acceptHooks Accept pre and post hooks if set to true. false true

Outputs

parameter description
outputDir Directory the cookiecutter outputted to

Runs

This action is a docker action.

Contributors

Thanks go to these wonderful people (emoji key):

Andrew
Andrew

💻 📖
Laura Armitage
Laura Armitage

💻 🐛