mopidy / cookiecutter-mopidy-ext

cookiecutter template for creating a Mopidy extension

Home Page:https://docs.mopidy.com/en/latest/extensiondev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error message: 'secrets' is undefined

bdunnette opened this issue · comments

Just attempted to run the cookiecutter as described - however, once all questions are answered I get the following error:

Unable to create file '.github/workflows/release.yml'
Error message: 'secrets' is undefined
Context: {
    "cookiecutter": {
        "_template": "gh:mopidy/cookiecutter-mopidy-ext",
        "author_email": "fake@email.com",
        "author_full_name": "Brian Dunnette",
        "dist_name": "Mopidy-Foobar",
        "ext_name": "foobar",
        "github_username": "bdunnette",
        "repo_name": "mopidy-foobar",
        "short_description": "Mopidy extension for Foobar mechanics",
        "version": "0.1.0",
        "year": "2020"
    }
}

...and no folder/code is generated.

Any suggestions as to how to remedy this?

I have exactly the same issue.
Ubuntu
Cookiecutter 1.7.2
(Python 3.6)
git version 2.17.1

here is a snip of output I get when running cookiecutter with -v

DEBUG cookiecutter.utils: Created directory at: /home/jon/projects/ToshibaRaspberryPiStreamer/code/mopidy-gpio-rgbencoder-pimoroni-1006/.github/workflows
DEBUG cookiecutter.generate: Processing file .github/workflows/release.yml
DEBUG cookiecutter.generate: Created file at /home/jon/projects/ToshibaRaspberryPiStreamer/code/mopidy-gpio-rgbencoder-pimoroni-1006/.github/workflows/release.yml
DEBUG cookiecutter.generate: Check .github/workflows/release.yml to see if it's a binary
Unable to create file '.github/workflows/release.yml'
Error message: 'secrets' is undefined

@bdunnette I took a dive into the cookiecutter code and it seems at that point it fails it is templating the .github/workflows/release.yml file. The line in the template that makes it fail is


The point of this file seems to be defining github actions for releasing the extension to PyPI.
From what I've read here: https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets
it seems you need to define your secrets in your github repository/environment/team
Unfortunately this seems to be something of a chicken-and-egg scenario where I was hoping to use cookiecutter to create the (barebones contents of the) repo but this seems to need the repo to exist first.
I'm not sure what the best way round this is. One idea would be to default the secrets if they don't exist so the template doesn't exist - although I'd probably want a warning if that happens.
I tried the following but it failed the same way.
password: ${{ secrets.PYPI_TOKEN |default(None)}}
For now I have cloned this cookiecutter repo locally and just deleted the .github/workflows/release.yml file - it would be easy enough to recreate it in my project later when I am getting to the point where I have something worth releasing.
Hope this helps,

Jon

Given .github is a hidden folder I am wondering if it was actually intentionally included - the idea might have been to keep it locally but have it ignored via a .gitignore.

The .github folder is intentionally included. The problem here is that GitHub Actions definitions and the Jinja2 template language used by cookiecutter both use {{ variable }} for variable insertion. I'll figure out a workaround :-)

It should work now. Please try again!

Yep, I can confirm it works for me now, thank you for a very speedy fix @jodal