Giter VIP home page Giter VIP logo

hector's Introduction

hector

CI & CD with JavaScript

WIP ๐Ÿšง Next: create plugins

Setup Hector (for use with :octocat: plugin)

  • chmod +x hector.js
  • set environment variables
    • set the environment variable HECTOR_PLUGIN_PATH eg: process.env["HECTOR_PLUGIN_PATH"] = "./plugins/github"
    • add a webhook in GitHub settings (http://hostname:port/ci)
      • you have to set a pass phrase (secret phrase)
      • and then setup CI_SECRET
    • TOKEN_BOT_CI
      • this is a personal access token
      • you can use a token from your personal settings
      • or a token from a "bot/virtual" user (the bot/virtual user has to exist in the team of the project)
    • GITHUB_API_URL (if you use :octocat: .com or Enterprise)
    • CI_HTTP_PORT
    • BOT_NOTIFICATION_URL (only if you use bot with a chat)
    • URL_WEB_SITE (url of the deployed web site, only if you need it)
  • add a file named hector-jobs.js to the master branch (tasks to run when something is pushed)
  • if you use docker for the deployment: add a Dockerfile to the master branch

Run Hector

  • run hector: ./hector.js or node hector.js

Job sample

hector-jobs.js at the root of master branch

function integration(options) {
  console.log(__dirname);
  let cmds = [
      `cd ${__dirname};`
    , `npm --cache-min 9999999 install; `
    , `npm test`
  ];
  return cmds.join('');
}

function deployment(options) {
  console.log("๐Ÿณ ๐Ÿณ ๐Ÿณ Docker deployment!")

  let cmds = [
      `cd ${__dirname};`
    , `docker stop demo-web-container;`
    , `docker rm demo-web-container;`
    , `docker build -t demo-web .; `
    , `docker run -p 9999:9999 --name demo-web-container -d -t -i demo-web`
  ];
  return cmds.join('');
}

module.exports = {
  integration: integration,
  deployment: deployment
}

package.json sample

{
  "name": "stools",
  "version": "1.0.0",
  "description": "",
  "main": "src/index.js",
  "dependencies": {
    "body-parser": "^1.15.2",
    "express": "^4.14.0"
  },
  "scripts": {
    "test": "./node_modules/.bin/mocha tests/**",
    "start": "./app.js"
  },
  "repository": {
    "type": "git"
  },
  "author": "@k33g",
  "license": "MIT",
  "devDependencies": {
    "chai": "^3.5.0",
    "mocha": "^2.5.3"
  }
}

Dockerfile sample

FROM mhart/alpine-node:7

MAINTAINER @k33g_org

ENV EXPRESS_PORT 9999

RUN mkdir -p /home/webapp
ADD package.json /home/webapp/package.json

WORKDIR home/webapp
RUN npm install

ADD . /home/webapp

EXPOSE 9999

CMD node app.js

hector's People

Contributors

k33g avatar

Stargazers

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