Skip to content

Update to Probot 7 and add readme #2

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

Merged
merged 7 commits into from
Sep 25, 2018
Merged

Update to Probot 7 and add readme #2

merged 7 commits into from
Sep 25, 2018

Conversation

tcbyrd
Copy link
Collaborator

@tcbyrd tcbyrd commented Sep 13, 2018

Here's an initial pass at the README for this. It's not intended to be a full primer on "how to serverless", but I do provide a few links to other resources. I think we can add more general info in our docs and link to that here as well, since some of the details will be the same between the various providers.

Feel free to edit. My brain isn't writing well today, so I'm sure some things may not be clear.

@tcbyrd tcbyrd requested review from JasonEtco and hiimbex September 13, 2018 22:41
Copy link
Member

@JasonEtco JasonEtco left a comment

Choose a reason for hiding this comment

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

Nice, this looks great! Left one tiny note, but feel free to 🚢 without it

Copy link

@hiimbex hiimbex left a comment

Choose a reason for hiding this comment

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

LGTM! I left comments about some small doc clarifications :)

## Differences from `probot run`

#### Local Development
Since Lambda functions do not start a normal node process, the best way we've found to test this out locally is to use [`serverless-offline`](https://github.com/dherault/serverless-offline). This plugin for the serverless framework emulates AWS Lambda and API Gateway on your local machine, allowing you to continue working from `https://localhost:3000/probot` before deploying your function to AWS.
Copy link

Choose a reason for hiding this comment

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

How to you actually use this plugin? Is there anything needed that's specific to probot?

README.md Outdated
Since Lambda functions do not start a normal node process, the best way we've found to test this out locally is to use [`serverless-offline`](https://github.com/dherault/serverless-offline). This plugin for the serverless framework emulates AWS Lambda and API Gateway on your local machine, allowing you to continue working from `https://localhost:3000/probot` before deploying your function to AWS.

#### Long running tasks
Some Probot Apps that depend on long running processes or intervals will not work with this extension. This is due to the inherent architecture of serverless functions, which are designed to respond to events and stop running as quickly as possible. For longer running apps we recommend using other deployment options such as [Glitch](https://probot.github.io/docs/deployment/#glitch) or [Now](https://probot.github.io/docs/deployment/#now).
Copy link

Choose a reason for hiding this comment

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

Maybe instead of just calling out these 2 we could just link to https://probot.github.io/docs/deployment ?

@bdougie
Copy link

bdougie commented Sep 18, 2018

Running through this as well. Is @probot/serverless-lambda already up on npm? If not, are there plans on making npm install @probot/serverless-lambda work?

I would love to pick up where this leaves off and write a brief guide leveraging this README, I am just not sure where to start to make this work.

@tcbyrd How were you testings this in the call last week? Do you have a link to your working repo that uses?

@tcbyrd
Copy link
Collaborator Author

tcbyrd commented Sep 18, 2018

Is @probot/serverless-lambda already up on npm?

Not yet. Someone setup the Probot scope/org already on NPM and we're not in it. Need to figure out who set it up. Otherwise I'd probably just publish it as probot-serverless-lambda.

I have an example here: https://github.com/tcbyrd/invite-koa/blob/developing/index.js, but until it's published on NPM you can do npm install probot/serverless-lambda to tell NPM will get it from this repo instead of a regular npm package.

If you're using a serverless.yml, here is how I defined the function handler:

https://github.com/tcbyrd/invite-koa/blob/d206f5897eaa1bdca29d480e9a685bfb3ee8a31c/serverless.yml#L16-L27

  probot:
    handler: index.handler


    environment:
      WEBHOOK_SECRET: ${file(config/config.${self:provider.stage}.json):WEBHOOK_SECRET}
      APP_ID: ${file(config/config.${self:provider.stage}.json):APP_ID}
      LOG_FORMAT: ${file(config/config.${self:provider.stage}.json):LOG_FORMAT}


    events:
      - http:
         path: /probot
         method: post

You don't have to use the config.{provider.stage}.json format for the environment variables, that's just a pattern I was following so I could run through some CI/CD workflows with Lambda. It will still pickup env variables from .env if that's in the .zip file you deploy.

GitHub
Port of probot/invite using Koa, deployed on Lambda - tcbyrd/invite-koa
GitHub
Port of probot/invite using Koa, deployed on Lambda - tcbyrd/invite-koa

@tcbyrd tcbyrd merged commit 34caaa4 into master Sep 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants