Skip to content

Instantly share code, notes, and snippets.

@itaditya
Last active April 12, 2018 08:08
Show Gist options
  • Save itaditya/41ee1e30abd86600ce46496f8f931596 to your computer and use it in GitHub Desktop.
Save itaditya/41ee1e30abd86600ce46496f8f931596 to your computer and use it in GitHub Desktop.
Workflow to test changes in Probot app locally without needing to push to production

Note - I use heroku for deploying prod app and for local I use smee for proxying webhook payload to localhost.

Instructions -

  • Deploy the probot app code to heroku.
  • Create two github apps say my-app and my-app-dev.
  • For my-app put the heroku url like http://my-app.herokuapp.com/ in Webhook URL.
  • For my-app-dev put the smee url like https://smee.io/aldnhksfh in Webhook URL.
  • For both apps use appropriate Webhook Secrets and download the private keys.
  • Rename the private keys to private-key.pem and private-key-dev.pem respectively.
  • In the .env file store the production config values (APP_ID, PRIVATE_KEY_PATH, WEBHOOK_SECRET).
  • For local development add these scripts in package.json and replace the config values with your my-app-dev one's.
  "scripts": {
    "start": "probot run ./index.js",
    "start:dev": "nodemon --exec \"npm start -- -a APP_ID -P private-key-dev.pem -W https://smee.io/aldnhksfh\"",
    "probot": "probot",
    "test": "jest && standard"
  }
  • Run npm i --save-dev nodemon.
  • For local development do npm run start:dev
  • With this, nodemon will restart my-app-dev probot app if code changes.
  • In heroku add the Config Vars according to the .env file. For PRIVATE_KEY use the content of private-key.pem.

Advantages -

  • No changes in code base.
  • Easy to manage.
  • Easy to deploy.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment