probot / adapter-aws-lambda-serverless

An extension for running Probot on Lambda
ISC License
94 stars 36 forks source link

Unable to comment on PR #79

Closed codezninja closed 3 years ago

codezninja commented 3 years ago

I'm trying to run the following probot using AWS Lambda that's getting events from a GHE instance.

  1. I used the example project and update the app.js to use the bot code.
  2. I also updated https://github.com/renovatebot/renovate-approve-bot/blob/80e0b5e0ea1d0b0b48862de39b813dce6cfd3d57/index.js#L47 to be return context.octokit.pulls.createReview(params); instead.

When the lambda triggers I am getting the following error

START RequestId: e62820aa-733b-4ef4-b750-c82ca20074fc Version: $LATEST
INFO (probot): App is loaded
INFO (event): Received PR open event
id: "d7c7fd70-100d-11ec-8fdd-a88238aa5068"
INFO (event): Approving new PR
id: "d7c7fd70-100d-11ec-8fdd-a88238aa5068"
ERROR (HttpError): Your private key (a .pem file or PRIVATE_KEY environment variable) or APP_ID is incorrect. Go to https://github.com/settings/apps/YOUR_APP, verify that APP_ID is set correctly, and generate a new PEM file if necessary.
HttpError: A JSON web token could not be decoded
at /var/task/src/node_modules/@octokit/request/dist-node/index.js:86:21
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async getInstallationAuthentication (/var/task/src/node_modules/@octokit/auth-app/dist-node/index.js:280:7)
at async hook (/var/task/src/node_modules/@octokit/auth-app/dist-node/index.js:449:7)
at async Job.doExecute (/var/task/src/node_modules/bottleneck/light.js:405:18) ```

I've set the following environment variables for the lambda

APP_ID
PRIVATE_KEY = (the value is from cat ghe_app_privateKey.pem)
WEBHOOK_SECRET
NODE_ENV
LOG_LEVEL

Running all this in nodejs12.x

codezninja commented 3 years ago

Figured it out, needed to update the code line to this

      const params = context.pullRequest({ event: APPROVE });
      return context.octokit.pulls.createReview(params)