dogsheep / github-to-sqlite

Save data from GitHub to a SQLite database
https://github-to-sqlite.dogsheep.net/
Apache License 2.0
402 stars 43 forks source link

Fall back to authentication via ENV #33

Closed garethr closed 4 years ago

garethr commented 4 years ago

Would you accept a PR that falls back to looking for an environment variable for the GitHub token? Specifically a change here: https://github.com/dogsheep/github-to-sqlite/blob/c34d5a18bfc41fa08755ba3d5cf9fe09ff204238/github_to_sqlite/cli.py#L271

I'd like to use github-to-sqlite in a GitHub Action workflow and this would be simpler than trying to fill out the prompt or generate a file with sensitive content.

Wanted to check first, I'm happy to submit a PR with tests and updates to the docs.

simonw commented 4 years ago

Sure, that sounds fine to me.

simonw commented 4 years ago

The auth.json mechanism this uses is standard across all of the other Dogsheep tools - it's actually designed so you can have one auth.json with a bunch of different credentials for different tools:

{
    "goodreads_personal_token": "...",
    "goodreads_user_id": "...",
    "github_personal_token": "...",
    "pocket_consumer_key": "...",
    "pocket_username": "...",
    "pocket_access_token": "..."
}

But... github-to-sqlite does feel like it deserves a special case here, since it's such a good fit for running inside of GitHub Actions - which even provide a GITHUB_TOKEN for you to use!

So I don't think it will harm the family of tools too much if this has an environment variable alternative to the -a file.

garethr commented 4 years ago

I also go it working with:

run: echo ${{ secrets.github_token }} | github-to-sqlite auth
simonw commented 4 years ago

Documented here: https://github.com/dogsheep/github-to-sqlite/blob/10fb34de41aaa35681f08b5991540d65bfcf2e2e/README.md#authentication