Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the new probot package @probot/get-private-key #52

Merged
merged 1 commit into from
Nov 20, 2020
Merged

Use the new probot package @probot/get-private-key #52

merged 1 commit into from
Nov 20, 2020

Conversation

mattkinnersley
Copy link
Contributor

@mattkinnersley mattkinnersley commented Nov 19, 2020

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.

Also updates README with more information on setting this up with environment variables.


View rendered README.md

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.
@@ -11,7 +11,7 @@ const loadProbot = (appFn) => {
new Probot({
id: process.env.APP_ID,
secret: process.env.WEBHOOK_SECRET,
privateKey: findPrivateKey(),
privateKey: getPrivateKey(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how would you usually configure the private key on lambda? I assume you wouldn't upload a *.pem file, so the only option really is to define the PRIVATE_KEY option? I think I'd remove the getPrivateKey method altogether and instead set

Suggested change
privateKey: getPrivateKey(),
privateKey: process.env.PRIVATE_KEY,

Copy link
Contributor Author

@mattkinnersley mattkinnersley Nov 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that getPrivateKey() does return process.env.PRIVATE_KEY as one of it's options and in the README there is a bit about using a .pem, I figured it would be safer to use this new package. But you're right, whenever I use lambda with serverless, I use the serverless-dotenv-plugin with .env files (also added this to the README).

I can't say for a fact it is impossible to use a *.pem so I thought this would give a bit of flexibility. As things stand, this package is unusable with the latest @probot which is the reason for this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As things stand, this package is unusable with the latest @probot which is the reason for this PR.

I agree, let's merge this PR and make a follow up PR for further discussion

@matushorvath
Copy link

matushorvath commented Nov 20, 2020

I can confirm that missing get-private-key file is an issue after updating the probot package to 10.17.1.
Thanks for creating this PR to fix it. In the meantime I think users of this package need to stay with Probot 10.15 or older.

{
    "errorType": "Runtime.ImportModuleError",
    "errorMessage": "Error: Cannot find module 'probot/lib/helpers/get-private-key'\nRequire stack:\n- /var/task/node_modules/@probot/serverless-lambda/index.js\n- /var/task/bin/index.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
    "stack": [
        "Runtime.ImportModuleError: Error: Cannot find module 'probot/lib/helpers/get-private-key'",
        "Require stack:",
        "- /var/task/node_modules/@probot/serverless-lambda/index.js",
        "- /var/task/bin/index.js",
        "- /var/runtime/UserFunction.js",
        "- /var/runtime/index.js",
        "    at _loadUserApp (/var/runtime/UserFunction.js:100:13)",
        "    at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
        "    at Object.<anonymous> (/var/runtime/index.js:43:30)",
        "    at Module._compile (internal/modules/cjs/loader.js:1015:30)",
        "    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)",
        "    at Module.load (internal/modules/cjs/loader.js:879:32)",
        "    at Function.Module._load (internal/modules/cjs/loader.js:724:14)",
        "    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)",
        "    at internal/main/run_main_module.js:17:47"
    ]
}

@gr2m gr2m merged commit b54ec1c into probot:master Nov 20, 2020
@github-actions
Copy link

🎉 This PR is included in version 1.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants