Code Monkey home page Code Monkey logo

deploy's Introduction

中文版说明

What's This?

Web service responses to GitHub Webhook.

Preconditions

This is not a Hello Word teaching example, but an actual project that I am using myself. Suppose you already know the following techniques or meet their conditions:

  • Have a server of your own
  • Could configure the domain name
  • Could configure nginx or other web server to forward the web service to the node service
  • Could create shell script
  • Know about node, koa
  • Know about Webhook
  • Know about SMTP

Features

  • After run node lib/index.js, a service that responds to GitHub Webhook is provided on port 3030.
  • Internally call the actual working shell script (you need to write it yourself) via exec
  • Send email for the result of script.

Configuration

Both are located in the config directory, refer to *_demo.json, add a version without _demo

config.json

You can create a corresponding configuration for each warehouse and branch:

{
  "webhook-test_master": { // RepositoryName_BranchName
    "secret": "GitHub_Webhook_secret",
    "cwd": "/home/jason/testapi/", // script execution directory
    "command": "/bin/bash ./deploy.sh", // Really work shell script
    "env": { // some environment variables
      "DEBUG": "s:*"
    }
  }
}

security.json

Currently, the SMTP configuration information is mainly stored for sending notification emails:

{
  "mailConfig": {
    "host": "email-smtp.us-west-2.amazonaws.com",
    "port": "465",
    "user": "user123",
    "password": "password123",
    "from": "[email protected]",
    "to": "[email protected]"
  }
}

Tips

For GitHub Webhook, remember to generate a secret and select the json format.

For shell scripts warn/error, which is not important, can be transferred from stderr to stdout via 2>&1.

For the mail service, I'm using Amazon SES. Everything is going well with 200 free mail quotas per day.

If you have a problem, ask Google and yourself; It works fine in my side.

deploy's People

Contributors

atjason avatar

Stargazers

Lyrics avatar

Watchers

James Cloos avatar Lyrics 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.