Giter VIP home page Giter VIP logo

heroku-redeploy's Introduction

heroku-redeploy

Heroku app to redeploy Heroku apps

Travis

This is a small Node.js app that can receive webhooks, and redeploy Heroku apps in response.

If you have a static site connected to a CMS, or another external data source, you can use this to trigger new Heroku builds on your apps. Heroku's Platform API doesn't have a simple way to redeploy an app using the same code and environment, which is why you might need to use a service like this.

Deploy

Setup

Deploying

Deploy this repository to Heroku, or whatever cloud service you like. Set these two env variables:

ENV_LIST=staging=appname-staging&production=appname-production
API_KEY=xxx-xxx

API_KEY is a Heroku API key. It needs to have permission to deploy all of the apps you configure.

ENV_LIST is a query string with what apps you want to deploy. The key is a nickname for the app, like dev, staging, or production. The value is the name of the Heroku app.

Webhooks

A basic webhook looks like this:

POST https://xxx.herokuapp.com/deploy?apps=staging

You can deploy multiple apps at once by separating them with commas:

POST https://xxx.herokuapp.com/deploy?apps=staging,production

You can also add a source parameter that tells the deployer where the webhook is coming from. This information will be added to the release description in Heroku, to give more context.

POST https://xxx.herokuapp.com/deploy?apps=staging,production&source=Contentful

The endpoint returns a JSON response with an array of apps that were targeted for redeployment. Note that ok: true only means that a new release was created—it doesn't mean it was successfully built.

[
  {
    "id": "staging",
    "app": "appname-staging",
    "ok": true,
    "version": 123
  },
  {
    "id": "production",
    "app": "appname-production",
    "ok": false,
    "error": "..."
  }
]

Security

If you want, you can require an authentication key to redeploy an app. In your app's environment, add the PASSWORD variable:

PASSWORD=swordfish

Then, in your requests, you can include the password in the URL with the access_token parameter:

POST https://xxx.herokuapp.com/deploy?apps=staging&access_token=swordfish

Or, you can include it in the Authorization header:

POST https://xxx.herokuapp.com/deploy?apps=staging
Authorization: Bearer swordfish

Local Development

git clone https://github.com/gakimballl/heroku-redeploy
cd heroku-redeploy
npm install
npm test

License

MIT © Geoff Kimball

heroku-redeploy's People

Contributors

gakimball avatar dependabot[bot] avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.