Skip to content
No description, website, or topics provided.
Python Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
Pipfile
Pipfile.lock
README.md
build_zappa_settings.py
deploy.sh
main.py
template.env

README.md

Wow! We now have a way to automatically close Heroku apps after they've been merged in or closed on github.

We use Zappa to deploy a serverless Python lambda function that runs a webhook every time there is a pull request on the Joplin branch.

If a PR on a branch besides "master" or "production" is closed or merged, then the heroku build for that branch will be destroyed, unless that heroku build has an environment variable called "DELETION_PROTECTION" set to a truthy value (preferably 1).

This lambda also runs a scheduled "joplin_cron_clean_up" job every day at midnight. This will delete heroku joplin PR builds that don't have a corresponding open PR and don't have DELETION_PROTECTION enabled. This is to catch clean_up jobs that failed to complete (for example, during race conditions where a PR is merged or closed before the circleci build completes).

Deployment

To redeploy this lambda function:

  1. Make sure you've got a valid GITHUB_WEBHOOK_SECRET_TOKEN and HEROKU_KEY in your .env file.
  2. Install dependencies pipenv install
  3. Run sh ./.circleci/cleanup/deploy.sh

Integrate with github

  1. In the Joplin repo on github, go to Settings > Webhooks.
  2. Edit or create a new webhook to listen on "pull_request" events.

Here's what you should plug in for the required values:

  • Payload URL
    • The "Payload URL" is the URL of the lambda function generated by Zappa at the route /postreceive.
    • ex: https://[random-string].execute-api.us-east-1.amazonaws.com/staging/postreceive
  • Secret
    • The "Secret" can be anything, as long as it's the same value plugged in as your "GITHUB_WEBHOOK_SECRET_TOKEN" environment variable.
  • Which events would you like to trigger this webhook?
    • Select "Let me select individual events."
    • Then choose "Pull requests"

Logging

Wait I don't want you to automatically delete my app

Set an environment variable within your Heroku PR build called "DELETION_PROTECTION" and set it equal to 1.

You can’t perform that action at this time.