This is a Heroku buildpack that enables authenticated GitHub operations within a Heroku dyno.
It detects a
GITHUB_AUTH_TOKEN environment variable and creates a
file with a GitHub entry.
It is the soul sister of the npm Buildpack.
See the blog post: npm and GitHub automation with Heroku
First, create a new GitHub access token at github.com/settings/tokens/new.
Then save this token in your Heroku app's config:
heroku config:set GITHUB_AUTH_TOKEN=YOUR_TOKEN_HERE
Then configure your app to use this buildpack:
heroku buildpacks:add --index 1 https://github.com/zeke/github-buildpack
The next time you push your app to Heroku, this buildpack will create a
.netrc file containing your GitHub token in the base directory of the app:
heroku run bash cat .netrc machine github.com login YOUR_TOKEN_HERE password x-oauth-basic
Now you can perform authenticated git operations on the dyno. Note that if
you want to
git commit, you'll need to specify the git user and email:
git clone https://github.com/you/some-private-repo cd some-private-repo git config user.email "email@example.com" git config user.name "Zeke Sikelianos" touch some/file git commit -am "git commit from a dyno!" git push origin master
This buildpack was inspired by @timshadel/heroku-buildpack-github-netrc, but the two differ in one significant way: the @timshadel buildpack allows authenticated requests to be made only at build time (i.e. when your app is being deployed), whereas this buildpack allows authenticated requests at build time and/or run time (when your app is actually running).
Copy the snippet above into CLI.