Skip to content

Commit b54ec1c

Browse files
fix: use @probot/get-private-key (#52)
Prior to this change, errors would occur when trying to access the old helper file. Probot no longer includes this helper file. This change adds the new package to make it compatible with the latest version of probot.
1 parent 910dea7 commit b54ec1c

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

README.md

+14
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,22 @@ module.exports.probot = serverless(appFn);
1919

2020
This package moves the functionality of `probot run` into a handler suitable for usage on AWS Lambda + API Gateway. Follow the documentation on [Environment Configuration](https://probot.github.io/docs/configuration/) to setup your app's environment variables. You can add these to `.env`, but for security reasons you may want to use the [AWS CLI](https://aws.amazon.com/cli/) or [Serverless Framework](https://github.com/serverless/serverless) to set Environment Variables for the function so you don't have to include any secrets in the deployed package.
2121

22+
To use `.env` files with the [Serverless Framework](https://github.com/serverless/serverless), you can install the [serverless-dotenv-plugin](https://www.serverless.com/plugins/serverless-dotenv-plugin). This will take care of keeping your secrets out of your deployed package.
23+
24+
### Serverless dotenv plugin usage
25+
```yaml
26+
plugins:
27+
- serverless-dotenv-plugin # Load .env as environment variables
28+
29+
provider:
30+
name: aws
31+
runtime: nodejs12.x
32+
```
33+
2234
For the private key, since AWS environment variables cannot be multiline strings, you could [Base64 encode](https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings) the `.pem` file you get from the GitHub App or use [KMS](https://aws.amazon.com/kms/) to encrypt and store the key.
2335

36+
37+
2438
## Differences from `probot run`
2539

2640
#### Local Development

index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const { Probot } = require("probot");
22
const { resolve } = require("probot/lib/helpers/resolve-app-function");
3-
const { findPrivateKey } = require("probot/lib/helpers/get-private-key");
3+
const { getPrivateKey } = require("@probot/get-private-key");
44
const { template } = require("./views/probot");
55

66
let probot;
@@ -11,7 +11,7 @@ const loadProbot = (appFn) => {
1111
new Probot({
1212
id: process.env.APP_ID,
1313
secret: process.env.WEBHOOK_SECRET,
14-
privateKey: findPrivateKey(),
14+
privateKey: getPrivateKey(),
1515
});
1616

1717
if (typeof appFn === "string") {

0 commit comments

Comments
 (0)