Skip to content

andrewthetechie/gha-cookiecutter

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

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 false false
skip Skip files if they already exist in outputDir if 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.