Skip to content

Generate a cookiecutter template in Github Actions

License

Notifications You must be signed in to change notification settings

bjss/gha-cookiecutter

 
 

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. 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

💻 🐛

About

Generate a cookiecutter template in Github Actions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 42.9%
  • Dockerfile 41.5%
  • Makefile 14.0%
  • Jinja 1.6%