I'm lost as to how to handle secret keys.
I've published a repo on GitHub with a secret key (I know now, big no no), then found out about the GitHub Secret Key in the settings and stored the key there.
So, two questions:
- what's the best way to clean the commit history so that the secret key isn't available anymore?
- how do I actually access this secret key? In my settings.py, I now had
SECRET_KEY = 'name_of_key_on_github'
but that throwsNameError: not defined
.
Any help is appreciated, thank you.
Update
Ok, so according to the link provided by @VonC, I need to create a .yml file in .github/workflows
directory.
general.yml
name: key #needed but name can be arbitrary
on: [push, pull_request, deployment]
env:
runs-on: ubuntu-latest
- uses: actions/labeler@v2
with:
repo-token: ${{ secrets.name_of_my_key }}
credentials: #these don't work yet, if anyone can tell me why?
username: ${{ github.actor }}
password: ${{ secrets.ghcr_token }}
settings.py
SECRET_KEY = "../.github/general.yml"
Project structure if you want / need to reproduce:
myrepo
├── app_name
│ ├── settings.py
├── .github
│ ├── workflows
│ │ ├── general.yml
I can run python manage.py runserver
, but on pushing to remote I get the following error:
! [remote rejected] master -> master (refusing to allow a Personal Access Token to create or update workflow `.github/workflows/general.yml` without `workflow` scope)
Update 2
Hadn't enabled the workflow scope (github.com > profile > settings > developer settings > personal access tokens):
You need to make sure box is checked.