Skip to content

Commit

Permalink
Merge pull request #9 from ecobee/revert-8-feature/add-support-for-gcp
Browse files Browse the repository at this point in the history
Revert "Feature/add support for gcp"
  • Loading branch information
nonAlgebraic authored Apr 10, 2019
2 parents af95de9 + d33711e commit 82d23bf
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 304 deletions.
8 changes: 1 addition & 7 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,4 @@ WEBHOOK_PROXY_URL=
PRIVATE_KEY=

# Get this api key from your SendGrid account.
SENDGRID_API_KEY=

# Google Cloud Platform project ID
GCP_PROJECT=consumer-web-dev-208518

# Credentials file for the df GCP API
GCP_CREDENTIALS=~/.gcloud/keyfile.json
SENDGRID_API_KEY=
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This is the repository for the **Release Buddy** Github bot. Release Buddy is in

### Application structure

`handler.js`: When you deploy this to a cloud function on GCP, handler.js will be the official entry point.
`handler.js`: When you deploy this to a lambda on AWS, handler.js will be the official entry point.

`index.js`: handler is really just a wrapper around the index file, which serves the bulk of the application code. When you run the application locally, it is being served by index.js.

Expand All @@ -26,26 +26,29 @@ yarn install
yarn start
```

- Visit the url that is created when you run your setup and follow the instructions to setup your github app. The webhook url can be your local smee url for now, but you will eventually want to replace this with the GCF url once you deploy it to GCP.
- Visit the url that is created when you run your setup and follow the instructions to setup your github app. The webhook url can be your local smee url for now, but you will eventually want to replace this with the lambda url once you deploy it to AWS.

- Add the required environment variables from the `.env.example` file to a `.env` file in the root folder.

- Setup serverless to work with your GCP account. See the [Quick Start](https://serverless.com/framework/docs/providers/google/guide/quick-start#pre-requisites) guide.
- Setup serverless to work with your AWS account. See the [Quick Start](https://serverless.com/framework/docs/providers/aws/guide/quick-start#pre-requisites) guide.

- Deploy the function using `yarn deploy`.
- Add the required environment variables to your [AWS Parameter Store](https://us-east-2.console.aws.amazon.com/systems-manager/parameters/create), so they can be accessed from the lambda once it has been deployed. You can find the references to these environment variables in the `serverless.yml` file under `functions` > `environment`. They should be entered into Parameter store using that same format (ex: `release-buddy-webhook-secret`).

- Update the webhook url Github App you created earlier in your [Developer settings](https://github.com/settings/apps). Select the app name you created, and edit the **Webhook URL** field to the URL of the GCF you deployed.
- Deploy the lambda using `yarn serverless deploy`.

- Update the webhook url Github App you created earlier in your [Developer settings](https://github.com/settings/apps). Select the app name you created, and edit the **Webhook URL** field to the AWS lambda field you deployed.

### Using Release Buddy in your project

Once you have setup the Release Buddy GCF and created the Github App, you can add Release Buddy to your Github projects following the directions below.
Once you have setup the Release Buddy AWS lambda server and created the Github App, you can add Release Buddy to your Github projects following the directions below.

- Add a `releaseBuddy.config.json` file to the root of your projects. See the configuration details below.

```json
``` json
{
"teamName": "Consumer Website Team", // Enter the name of your team.
"slackSettings": {

"enabled": true, // enable/disable the Slack notifier
"slackWebhookUrl": "https://hooks.slack.com/your-slack-webhook-url-here", // your Slack webhook url
"userName": "Release Buddy", // Slackbot user name
Expand All @@ -54,8 +57,8 @@ Once you have setup the Release Buddy GCF and created the Github App, you can ad
"shipEmojis": ":ship: :ship_it_parrot: :rocket: :ship_it_parrot: :ship:" // These will appear in the slack message to add some pizazz to your release message
},
"emailSettings": {
"enabled": true, // enable/disable the email notifier
// Sendgrid api docs for formatting: https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/index.html
"enabled": true, // enable/disable the email notifier
// Sendgrid api docs for formatting: https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/index.html
"to": {
"name": "Release Buddy", // Replace with any name.
"email": "no-reply@ecobee.com" // Replace with email of your choice.
Expand Down
4 changes: 2 additions & 2 deletions handler.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// handler.js
const { serverless } = require('@probot/serverless-gcf')
const appFn = require('./index')
const { serverless } = require('@probot/serverless-lambda')
const appFn = require('./')

module.exports.probot = serverless(appFn)
11 changes: 3 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,21 @@
"github",
"probot-app"
],
"main": "handler.js",
"scripts": {
"simulate": "yarn probot simulate release test/fixtures/release.published.json ./index.js",
"dev": "nodemon",
"start": "probot run ./index.js",
"lint": "standard --fix",
"test": "jest",
"test:watch": "jest --watch --notify --notifyMode=change --coverage",
"deploy": "node_modules/.bin/dotenv serverless deploy"
"test:watch": "jest --watch --notify --notifyMode=change --coverage"
},
"dependencies": {
"@probot/serverless-gcf": "^0.2.0",
"@probot/serverless-lambda": "^0.2.0",
"@sendgrid/mail": "^6.3.1",
"dotenv": "^7.0.0",
"dotenv-cli": "^2.0.0",
"markdown": "^0.5.0",
"node-fetch": "^2.2.0",
"probot": "^7.2.0",
"remove-markdown": "^0.3.0",
"serverless-google-cloudfunctions": "^2.3.2",
"slackify-markdown": "^1.0.4"
},
"devDependencies": {
Expand All @@ -42,7 +37,7 @@
"eslint-plugin-jsx-a11y": "^6.1.1",
"eslint-plugin-react": "^7.11.0",
"jest": "^22.4.3",
"nodemon": "^1.18.10",
"nodemon": "^1.17.2",
"prettier": "^1.14.2",
"serverless": "^1.34.1",
"serverless-offline": "^3.25.17",
Expand Down
26 changes: 11 additions & 15 deletions serverless.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
service: release-buddy

package:
exclude:
- ./test/**

provider:
name: google
runtime: nodejs8
project: ${env:GCP_PROJECT}
credentials: ${env:GCP_CREDENTIALS}
name: aws
runtime: nodejs8.10
region: us-east-1

plugins:
- serverless-google-cloudfunctions
- serverless-offline

functions:
release-buddy:
handler: probot
handler: handler.probot

environment:
WEBHOOK_SECRET: ${env:WEBHOOK_SECRET}
PRIVATE_KEY: ${env:PRIVATE_KEY}
APP_ID: ${env:APP_ID}
SENDGRID_API_KEY: ${env:SENDGRID_API_KEY}
WEBHOOK_SECRET: ${ssm:release-buddy-webhook-secret}
PRIVATE_KEY: ${ssm:release-buddy-private-key}
SENDGRID_API_KEY: ${ssm:release-buddy-sendgrid-api-key}
APP_ID: ${ssm:release-buddy-app-id}
LOG_FORMAT: json

events:
- http: /probot
- http:
path: /probot
method: post
2 changes: 1 addition & 1 deletion test/index.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { Application } = require('probot')
// Requiring our app implementation
const myProbotApp = require('../index')
const myProbotApp = require('..')

const releasePublishedPayload = require('./fixtures/release.published.json')
const { slackAndEmail, emailOnly, slackOnly } = require('./fixtures/releaseBuddy.config')
Expand Down
Loading

0 comments on commit 82d23bf

Please sign in to comment.