Collect statistics about githb repositories
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
assets
images
lib
tasks
tests
tools
.editorconfig
.env-demo
.gitignore
.travis.yml
Dockerfile
README.md
docker-compose.standalone.yml
docker-compose.yml
package.json
yarn.lock

README.md

Github statistics collector

Build Status

XO code style

Demo app to collect and show statistics about user's public github projects

Demo1

Demo2

Prerequisites

If you are going to make manual build you also need

Deploy

Preparation

Go to Developer settings of your github account. Create new "OAuth App".

Create OAuth App

Fill all required fieds. Set to "Authorization callback URL" value https://your_host_domain_name/github/callback where your_host_domain_name is host name where this app will be hosted. Press "Register application".

OAuth App settings

Copy Client ID and Client Secret of created app. These values will be required later.

OAuth2 data

Create empty directory for the app. Open terminal in it. Download config file template.

curl https://raw.githubusercontent.com/BandwidthExamples/github-stats/master/.env-demo > .env

Open config file .env in your favorite editor and fill it.

If you are going to use docker for deployment add current user to group docker (sudo usermod -a -G docker <your-user>) to avoid using of sudo later. Don't forget restart session after that.

Deploy: easiest way

As standalone app

# docker-compose should be preinstalled

# next options are required to get free https certificate via Let's Encrypt
export HOST=<your-host-domain-name>
export EMAIL=<your-email>

curl -o- https://raw.githubusercontent.com/BandwidthExamples/github-stats/master/tools/install-standalone.sh | bash

# Check that all services have been started (Up)
docker-compose ps

# Check you system if ports 80 and 443 are opened.

As backend for existing frontend web server

# docker-compose should be preinstalled
export PORT=<internal-port-for-your-frontend-server>

curl -o- https://raw.githubusercontent.com/BandwidthExamples/github-stats/master/tools/install-backend.sh | bash

# Check that all services have been started (Up)
docker-compose ps

Deploy: via docker

As standalone app

# create directory to store database files
mkdir db

# create directory to store files (and certificated) of frontend web-server
mkdir .caddy

# download required files
curl https://raw.githubusercontent.com/BandwidthExamples/github-stats/master/docker-compose.standalone.yml > docker-compose.yml
curl https://raw.githubusercontent.com/BandwidthExamples/github-stats/master/tools/Caddyfile -O

# open Caddyfile in your favorite editor and replace string EMAIL by your email, HOST by your host domain name (these data are required to receive free https certs on Let's Encrypt)
vim Caddyfile

# Run the app
docker-compose up -d

# Check that all services have been started (Up)
docker-compose ps

# Check you system if ports 80 and 443 are opened.

As backend for existing frontend web server

# create directory to store database files
mkdir db

# set port which the app will listen to
export PORT=<internal-port-for-your-frontend-server>

# download required file
curl https://raw.githubusercontent.com/BandwidthExamples/github-stats/master/docker-compose.yml -O

# Run the app
docker-compose up -d

# Check that all services have been started (Up)
docker-compose ps

As backend for existing frontend web server and external MongoDB instance

docker run -d --restart=always -p <internal-port-for-your-frontend-server>:3000 -e DATABASE_URL=<url_to_your_external_mongodb_collection> -e NODE_ENV=production --env-file .env bandwidthexamples/github-stats

Deploy: manual build

# clone this project
git clone https://github.com/BandwidthExamples/github-stats
cd github-stats

# copy filled .env file
cp ../.env .

# configure connection to Mongo Db. If need install and start MongoDB server
export DATABASE_URL=<url_to_your_external_mongodb_collection>

# configure your frontend web server to use https and redirect calls to specific port (or use ngrok) and set this port to variable PORT
export PORT=<internal-port-for-your-frontend-server>

# switch node to production environment
export NODE_ENV=production

# install dependencies
yarn install

# build frontend
yarn run build

# start this app
yarn start

Add to cron or another system scheduler daily executing of yarn run task collect-stats in current working directory.

Develop

# clone this project
git clone https://github.com/BandwidthExamples/github-stats
cd github-stats

# install dependencies
yarn install

# copy template file for settings and fill it
cp ./.env-demo ./.env
vim .env

# set required env variables
export DATABASE_URL=<url_to_your_external_mongodb_collection>
export PORT=<port_to_forward_calls>

# run app in develpment mode
yarn run dev

# run collecting of git stats by command
yarn run task collect-stats