Skip to content
This repository has been archived by the owner on Dec 21, 2020. It is now read-only.

Commit

Permalink
chore(updates): update deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberhck committed Jul 13, 2019
1 parent 3e2d636 commit 1d0ab28
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 20 deletions.
19 changes: 4 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,12 @@ language: node_js
node_js:
- "10"

cache:
directories:
- node_modules
- /usr/local/lib/node_modules

before_install:
- npm install -g greenkeeper-lockfile@1

before_script: greenkeeper-lockfile-update

script:
- npm run build -s
- npm run test -s
- npm run lint -s

after_script: greenkeeper-lockfile-upload

after_success:
- bash <(curl -s https://codecov.io/bash)
#- npm run semantic-release
deploy:
provider: script
script: "./scripts/deploy.sh"
skip_cleanup: true
21 changes: 21 additions & 0 deletions now.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"version": 2,
"name": "handlebar-templates",
"alias": "ht",
"builds": [
{
"src": "/lib/index.js",
"use": "@now/node"
}
],
"routes": [
{
"src": "/.*",
"dest": "/lib/index.js"
}
],
"env": {
"LOG_LEVEL": "info",
"NODE_ENV": "production"
}
}
9 changes: 9 additions & 0 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
set -e
echo "running npm install"
npm install
echo "Deploying application"
echo "setting up now variable"
now="npx now --debug --token=$NOW_TOKEN"
echo "$ now --no-verify"
${now} -e APP_ID=${APP_ID} -e WEBHOOK_SECRET=${WEBHOOK_SECRET} -e PRIVATE_KEY_ENCODED=${PRIVATE_KEY_ENCODED}
8 changes: 8 additions & 0 deletions src/App.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {App} from "./App";

describe("App", () => {
it("should be defined", () => {
expect(App).toBeDefined();
expect(App.handle).toBeDefined();
});
});
6 changes: 2 additions & 4 deletions src/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,15 @@ export class App {
}

private static async handleEvent(context: Context<TData>): Promise<void> {
context.log.info("handling event");
const body = App.getBody(context.payload);
const templateVars = App.getTemplateVars(context.payload);
context.log.info("template vars:", templateVars);
const newBody = App.getCompiledBody(body, templateVars);
if (App.isPr(context.payload)) {
await context.github.pulls.update(context.issue({body: newBody}));
context.log.info("updated PR body");
context.log.debug("updated PR body");
} else {
await context.github.issues.update(context.issue({body: newBody}));
context.log.info("updated ISSUE body");
context.log.debug("updated ISSUE body");
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/AppConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const getAppConfig = (): IAppConfig => {
return {
id,
port: 3000,
secret: "cec47effc2b7d4c317d2dea65fc70384c3bcf8a7", // process.env.WEBHOOK_SECRET,
secret: process.env.WEBHOOK_SECRET,
cert: Buffer.from(process.env.PRIVATE_KEY_ENCODED, "base64").toString("ascii")
};
};

0 comments on commit 1d0ab28

Please sign in to comment.