diff --git a/.env b/.env new file mode 100644 index 0000000..f057b9d --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ +# See README for instructions on generating Github token +GITHUB_READ_API_TOKEN=1234 diff --git a/.gitignore b/.gitignore index 875b818..49a6ba3 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,5 @@ .rspec_status *.iml Gemfile.lock + +.env.local diff --git a/Gemfile b/Gemfile index 2486a11..95ae593 100644 --- a/Gemfile +++ b/Gemfile @@ -3,6 +3,7 @@ source "https://rubygems.org" # Specify your gem's dependencies in library_version_analysis.gemspec gemspec +gem 'dotenv-rails', "~> 2.8.1", groups: [:development, :test] gem "rake", "~> 12.0" gem "rspec", "~> 3.0" diff --git a/README.md b/README.md index d3bd47d..3c8a0d5 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,15 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). +To run the shell script locally, you must first set up the environment variables in the `.env.local` file. +To generate the Github token, follow these steps: +1. From any page on Github, click your icon at the top right, and click Settings +2. Click Developer Settings in the left panel +3. Click Personal Access Tokens and then `Tokens Classic` +4. Click Generate New Token -> Generate new token (classic) +5. Create a token with the `Repo` scope enabled +6. Add the token to the `.env.local` file under the `GITHUB_READ_API_TOKEN` entry + ## Jobber Dev Update the gemfile to read: jgem :enablers, "library_version_analysis", path: "/Users/johnz/source/library_version_analysis" diff --git a/lib/library_version_analysis/github.rb b/lib/library_version_analysis/github.rb index 06db8a8..b72b0c0 100644 --- a/lib/library_version_analysis/github.rb +++ b/lib/library_version_analysis/github.rb @@ -1,5 +1,6 @@ require "graphql/client" require "graphql/client/http" +require 'dotenv/load' module LibraryVersionAnalysis class Github