forked from mirrors/probot
Merge remote-tracking branch 'origin/master' into raven-log
* origin/master: Release v0.4.0. Update log for local server Remove tunnel script Move subdomain config Update docs to use localtunnel Add subdomain option Setup tunnel using localtunnel Ensure node version is satisfied
This commit is contained in:
commit
f40d2376d3
|
@ -4,3 +4,6 @@ WEBHOOK_SECRET=development
|
||||||
|
|
||||||
# Uncomment this to get verbose logging
|
# Uncomment this to get verbose logging
|
||||||
# LOG_LEVEL=trace # or `info` to show less
|
# LOG_LEVEL=trace # or `info` to show less
|
||||||
|
|
||||||
|
# Subdomain to use for localtunnel server. Defaults to your local username.
|
||||||
|
# SUBDOMAIN=
|
||||||
|
|
|
@ -1,5 +1,13 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
const semver = require('semver');
|
||||||
|
const version = require('../package').engines.node;
|
||||||
|
|
||||||
|
if (!semver.satisfies(process.version, version)) {
|
||||||
|
console.log(`Node.js version ${version} is required. You have ${process.version}.`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
require('commander')
|
require('commander')
|
||||||
.version(require('../package').version)
|
.version(require('../package').version)
|
||||||
.usage('<command> [options]')
|
.usage('<command> [options]')
|
||||||
|
|
|
@ -17,6 +17,7 @@ program
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
}, process.env.PRIVATE_KEY)
|
}, process.env.PRIVATE_KEY)
|
||||||
|
.option('-t, --tunnel <subdomain>', 'Expose your local bot to the internet', process.env.SUBDOMAIN || process.env.NODE_ENV != 'production')
|
||||||
.parse(process.argv);
|
.parse(process.argv);
|
||||||
|
|
||||||
if(!program.integration) {
|
if(!program.integration) {
|
||||||
|
@ -36,6 +37,34 @@ if(!program.privateKey) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(program.tunnel) {
|
||||||
|
try {
|
||||||
|
setupTunnel();
|
||||||
|
} catch(err) {
|
||||||
|
console.warn('Run `npm install --save-dev localtunnel` to enable localtunnel.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setupTunnel() {
|
||||||
|
const localtunnel = require('localtunnel');
|
||||||
|
const subdomain = typeof program.tunnel == 'string' ?
|
||||||
|
program.tunnel :
|
||||||
|
require('os').userInfo().username;
|
||||||
|
|
||||||
|
const tunnel = localtunnel(program.port, {subdomain}, function (err, tunnel) {
|
||||||
|
if (err) {
|
||||||
|
console.warn('Could not open tunnel: ', err.message);
|
||||||
|
} else {
|
||||||
|
console.log('Listening on ' + tunnel.url);
|
||||||
|
tunnel.url;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
tunnel.on('close', function() {
|
||||||
|
console.warn('Local tunnel closed');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const pkgConf = require('pkg-conf');
|
const pkgConf = require('pkg-conf');
|
||||||
const resolve = require('resolve').sync;
|
const resolve = require('resolve').sync;
|
||||||
const createProbot = require('../');
|
const createProbot = require('../');
|
||||||
|
|
|
@ -3,23 +3,18 @@
|
||||||
To run a plugin locally, you'll need to create a GitHub Integration and configure it to deliver webhooks to your local machine.
|
To run a plugin locally, you'll need to create a GitHub Integration and configure it to deliver webhooks to your local machine.
|
||||||
|
|
||||||
1. Make sure you have a recent version of [Node.js](https://nodejs.org/) installed
|
1. Make sure you have a recent version of [Node.js](https://nodejs.org/) installed
|
||||||
1. Install [ngrok](https://ngrok.com/download) (`$ brew cask install ngrok` on a mac), which will expose the local server to the internet so GitHub can send webhooks
|
|
||||||
1. Run `$ ngrok http 3000` to start ngrok, which should output something like `Forwarding https://4397efc6.ngrok.io -> localhost:3000`
|
|
||||||
1. [Create a new GitHub Integration](https://github.com/settings/integrations/new) with:
|
1. [Create a new GitHub Integration](https://github.com/settings/integrations/new) with:
|
||||||
- **Callback URL** and **Webhook URL**: The full ngrok url above. For example: `https://4397efc6.ngrok.io/`
|
- **Webhook URL**: Set to `https://example.com/` and we'll update it in a minute.
|
||||||
- **Webhook Secret:** `development`
|
- **Webhook Secret:** `development`
|
||||||
- **Permissions & events** needed will depend on how you use the bot, but for development it may be easiest to enable everything.
|
- **Permissions & events** needed will depend on how you use the bot, but for development it may be easiest to enable everything.
|
||||||
1. Download the private key and move it to the project directory
|
1. Download the private key and move it to the project directory
|
||||||
1. Edit `.env` and set `INTEGRATION_ID` to the ID of the integration you just created.
|
1. Edit `.env` and set `INTEGRATION_ID` to the ID of the integration you just created.
|
||||||
1. With `ngrok` still running, open another terminal and run `$ npm start` to start the server on http://localhost:3000
|
1. Run `$ npm start` to start the server, which will output `Listening on https://yourname.localtunnel.me`;
|
||||||
|
1. Update the **Webhook URL** in the [integration settings](https://github.com/settings/integrations) to use the `localtunnel.me` URL.
|
||||||
|
|
||||||
You'll need to create a test repository and install your Integration by clicking the "Install" button on the settings page.
|
You'll need to create a test repository and install your Integration by clicking the "Install" button on the settings page.
|
||||||
|
|
||||||
Whenever you com back to work on the app after you've already had it running once, then you need to:
|
Whenever you com back to work on the app after you've already had it running once, you should only need to run `$ npm start`.
|
||||||
|
|
||||||
1. Run `$ npm start`
|
|
||||||
1. Run `$ ngrok http 3000` in another terminal window
|
|
||||||
1. `ngrok` will use a different URL every time it is restarted, so you will have to go into the [settings for your Integration](https://github.com/settings/integrations) and update all the URLs.
|
|
||||||
|
|
||||||
## Debugging
|
## Debugging
|
||||||
|
|
||||||
|
|
|
@ -107,8 +107,6 @@ $ probot run -i 9999 -P private-key.pem ./autoresponder.js
|
||||||
Listening on http://localhost:3000
|
Listening on http://localhost:3000
|
||||||
```
|
```
|
||||||
|
|
||||||
Once your bot is running, you'll need to use `ngrok` to receive GitHub webhooks as described in the [development](development.md) documentation.
|
|
||||||
|
|
||||||
## Publishing your bot
|
## Publishing your bot
|
||||||
|
|
||||||
Plugins can be published in NPM modules, which can either be deployed as stand-alone bots, or combined with other plugins.
|
Plugins can be published in NPM modules, which can either be deployed as stand-alone bots, or combined with other plugins.
|
||||||
|
|
2
index.js
2
index.js
|
@ -50,7 +50,7 @@ module.exports = options => {
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
server.listen(options.port);
|
server.listen(options.port);
|
||||||
logger.info('Listening on http://localhost:' + options.port);
|
logger.trace('Listening on http://localhost:' + options.port);
|
||||||
},
|
},
|
||||||
|
|
||||||
load(plugin) {
|
load(plugin) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "probot",
|
"name": "probot",
|
||||||
"version": "0.3.2",
|
"version": "0.4.0",
|
||||||
"description": "a trainable robot that responds to activity on GitHub",
|
"description": "a trainable robot that responds to activity on GitHub",
|
||||||
"repository": "https://github.com/probot/probot",
|
"repository": "https://github.com/probot/probot",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
ngrok http -bind-tls=true 3000
|
|
Loading…
Reference in New Issue