https://sef-github-leaderboard.herokuapp.com/
( Upgade to MySQL 8.0 if you are using lower versions )
- Create new mysql user for sef
CREATE USER 'sef'@'localhost' IDENTIFIED BY 'sef123';
- Grant access to the new user
GRANT ALL PRIVILEGES ON *.* TO 'sef'@'localhost';
- Run the mysql.sql script in scripts directory to import the database.
mysql> source scripts\mysql.sql;
-
Replace the respective properties in the application.properties file
vim src/main/resources/application.properties
${DB_NAME}
- Database name + ?useSSL=false${DB_URL}
- 127.0.0.1:3306${DB_USERNAME}
- Database name${DB_PASSWORD}
- Database name
-
Add a random String as the webhook key in configprops.properties file
vim src/main/resources/configprops.properties
replace
${WEBHOOK_KEY}
key with your random string. -
Build the project using maven
mvn clean install
-
Run the generated jar file
java -jar target/sef-github-leaderboard-1.5.9.RELEASE.jar
-
Access the UI by visiting
http://localhost:9090/
Now that our webhook is ready to deliver messages.
Recall that we specifically set our webhook URL to http://localhost:8080/api/github-leaderboad/v1/webhook/{YOUR_KEY}
.
Since we're developing locally, we'll need to expose our local development environment to the Internet, so that GitHub
can send out messages, and our local server can process them.
First, we'll install a program to expose our local host to the Internet. We'll use ngrok to do this. ngrok is a free download available for all major operating systems.
When you're done with that, you can expose your localhost by running ./ngrok http 8080
on the command line.
You should see a line that looks something like this:
Forwarding http://7e9ea9dc.ngrok.io -> 127.0.0.1:8080
Copy that funky *.ngrok.io
URL! We're now going to go back to the Payload URL and pasting this server into that field.
It should look something like http://7e9ea9dc.ngrok.io/api/github-leaderboad/v1/webhook/{YOUR_KEY}
. It is our webhook
URL.
By doing this, we've set ourselves up to expose our localhost
at path /api/github-leaderboad/v1/webhook/{YOUR_KEY}
to the Internet.
To set up a webhook, go to the settings page of your repository or organization. From there, click Webhooks, then Add webhook.
Payload URL
- Our Webhook url
Content type
- application/json
Which events would you.. webhook?
- Select 'Let me select individual events.' & select Pull requests
Now send a pull request to your repo and merge to test.
Rejoice!!!
If you need to test with dummy data, you can import the the database located in the scripts directory dummy_data.sql
mysql -u user_name -p database_name < scripts/dummy_data.sql