A Rails app that provides a simple and frictionless way for users to publish data on Github.
More information is in the announcement blog post.
Live instance is running at http://octopub.io/
Octopub interfaces with a number of other services, including GitHub, AWS, Pusher etc so your .env file will require the following for dev, test and production. Further details on setting this up are below.
# Github Client ID
GITHUB_KEY=
# Github Client Secret
GITHUB_SECRET=
GITHUB_USER=
S3_BUCKET=
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
PUSHER_APP_ID=
PUSHER_KEY=
PUSHER_SECRET=
PUSHER_CLUSTER=
BASE_URI=
ODC_API_KEY=
ODC_USERNAME=
Create a github application
- Log in to github and go to
settings
- Click on
OAuth applications
in theDeveloper settings
section - Create a new OAuth application with a unique name, you can use http://octopub.io for the hompage. For the callback URL use your local dev machine's address, i.e. http://octopub.dev
Once created, you can use the client ID and client secret in your .env
file as follows:
GITHUB_KEY=<whatever your Client ID is>
GITHUB_SECRET=<whatever your client secret is>
GITHUB_TOKEN=???
Create an AWS S3 bucket and grant it's permissions accordingly
- Log in to your AWS account and create an S3 bucket with a sensible name
- Now head to the AWS IAM (Identity and Access Management page)
- Click
Users
- Add user (call it something sensible like octopub-development) and select
Programmatic Access for Access Type
. - For permissions, select
Attach existing policies directly
- this will open a new tab in your browser. - CLick
create your own policy
and give it a name, likeoctopub-dev-permissions
, then for the policy document, use the following template, but add your own bucket name instead of<BUCKETNAME>
.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowAdminAccessToBucketOnly",
"Action": [
"s3:*"
],
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::<BUCKETNAME>",
"arn:aws:s3:::<BUCKETNAME>/*"
]
}
]
}
- Click
validate policy
just to be sure you've not made a typo. Then confirm. - Now back on the
Set permissions page
, select the policy you've just created in the table by selecting the checkbox. Then clickReview
thenCreate user
. - Now download the
csv file
containing the credentials and add the following to your.env
file
AWS_ACCESS_KEY_ID=<YOURNEWUSERACCESSKEY>
AWS_SECRET_ACCESS_KEY=<YOURNEWUSERSECRET>
S3_BUCKET=<YOURNEWS3BUCKETNAME>
- Log in to https://pusher.com
- Create a new application and call it something sensible
- Select the
App Keys
tab and get the values and paste them in to your.env
file
PUSHER_APP_ID=
PUSHER_KEY=
PUSHER_SECRET=
NOTE: You may be set up for a non-default Pusher cluster (The default is us-east-1
), which causes some confusion. Look at your App overiew on pusher.com and get the Cluster value from the 'Keys' section. Add this to your .env
file as PUSHER_CLUSTER=
Assuming you have an account, if not, create one at https://certificates.theodi.org/
Get your API Authentication token from your profile page when logged in and add the following to your .env
file
ODC_API_KEY=<API Key>
ODC_USERNAME=<your username which is your email address you used when signing up>
Ensure you have ruby & bundler set up (currently using Ruby 2.4)
Checkout the repository and run bundle
in the checked out directory.
The application uses sidekiq for managing the background proccessing of data uploads. To use this functionality, install redis
either by following the instructions or if on macOS and using homebrew, run brew install redis
and start a redis instance running with redis-server
.
Octopub uses the rspec
test framework and the test suite can be run with the usual bundle exec rspec
.
It requires the presence of a .env
- see earlier section for details - you can use your development variables, the tests use VCR or mocking to allow the tests to be run offline without interfacing with the services.
Pre-requisites, GitHub account, AWS account, Pusher Account, Open Data Certificate account - these instructions assume you have these in place already.
- Make sure redis is running
redis-server
- Make sure Sidekiq is running
bundle exec sidekiq
in the application directory - Start the application
- Go to index page
- Sign in with github (your acocunt)
- Authorise in github
- Congratulations, you should be signed in, now try adding some data.
in a rails console session
require 'sidekiq/api'
Sidekiq::Queue.new.size
Sidekiq::Queue.new.first
A commit to master will trigger a TravisCI run, which, if successful, will automatically deploy to Heroku.
The GitHub organisations are cached for the logged in user, they can be cleared from a console with Rails.cache.clear