Skip to content

cityofaustin/coa-joplin-clean-up

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 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.

About

Office of Design and Delivery

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages