Files
metrics/.github/readme/partials/setup/web/setup.md
2021-04-11 10:03:44 +02:00

2.3 KiB

💬 How to setup?

0. Prepare your server

You'll need a server with a recent version NodeJS (see used version in Dockerfile).

1. Create a GitHub personal token

From the Developer settings of your account settings, select Personal access tokens to create a new token.

No additional scopes are needed.

Setup a GitHub personal token

2. Install dependencies

Clone repository, install dependencies and copy configuration example to settings.json:

git clone https://github.com/lowlighter/metrics.git
cd metrics/
npm install --only=prod
cp settings.example.json settings.json

3. Configure your instance and start it

Edit settings.json to configure your instance.

{
  //GitHub API token
    "token":"GITHUB_TOKEN",
  //Other options...
}

See all supported options in settings.example.json.

If you plan to make your web instance public, it is advised to restrict its access thanks to rate limiter and access list.

Once you've finished configuring metrics, start your instance:

npm start

Access your server with provided port in setting.json from your browser to ensure everything is working.

Edit your repository readme and add your metrics image from your server domain:

![Metrics](https://my-personal-domain.com/my-github-user)

6. (optional) Setup your instance as a service

To ensure that your instance will restart if it reboots or crashes, you should set it up as a service. This is described below for Linux-like systems which support systemd.

Create a new service file /etc/systemd/system/github_metrics.service and paste the following after editing paths inside:

[Unit]
Description=Metrics
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
WorkingDirectory=/path/to/metrics
ExecStart=/usr/bin/node /path/to/metrics/index.mjs

[Install]
WantedBy=multi-user.target

Reload services, enable it, start it and check if it is up and running:

systemctl daemon-reload
systemctl enable github_metrics
systemctl start github_metrics
systemctl status github_metrics