Code Monkey home page Code Monkey logo

jekyll-hook's Introduction

"Build-hook"

This project is a fork of jekyll-hook, a server that listens for a webhook from Github to build a Jekyll server. The aim is to have it render any type of Ruby (Padrino-style) compiled website from Heroku.

This is a work on progress, and contributions and help are gladly welcome.

Do not base

As this will eventually be a Pull Request, I rebase frequently. You are warned.

jekyll-hook

A server that listens for webhook posts from GitHub, generates a website with Jekyll, and moves it somewhere to be published. Use this to run your own GitHub Pages-style web server. Great for when you need to serve your websites behind a firewall, need extra server-level features like HTTP basic auth (see below for an NGINX config with basic auth), or want to host your site directly on a CDN or file host like S3. It's cutomizable with two user-configurable shell scripts and a config file.

Installation

  • run $ npm install to install app dependencies
  • Set a Web hook on your GitHub repository that points to your jekyll-hook server http://example.com:8080/hooks/jekyll/:branch, where :branch is the branch you want to publish. Usually this is gh-pages or master for *.github.com / *.github.io repositories.

Configuration

Adjust build.sh and publish.sh to suit your workflow. By default, they generate a site with Jekyll and publish it to an NGINX web directory.

Copy config.sample.json to config.json in the root directory and customize.

Configuration attributes:

  • gh_server The GitHub server from which to pull code
  • temp A directory to store code and site files
  • scripts
    • build A script to run to build the site
    • publish A script to run to publish the site
  • email Optional. Settings for sending email alerts
    • user Sending email account's user name (e.g. [email protected])
    • password Sending email account's password
    • host SMTP host for sending email account (e.g. smtp.gmail.com)
    • ssl true or false for SSL
  • accounts An array of accounts or organizations whose repositories can be used with this server

Usage

  • run as executable: $ ./jekyll-hook.js

Publishing content

The stock build.sh copies rendered site files to subdirectories under a web server's www root directory. For instance, use this script and NGINX with the following configuration file to serve static content behind HTTP basic authentication:

server {
    root /usr/share/nginx/www;
    index index.html index.htm;

    # Make site accessible from http://localhost/
    server_name localhost;

    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to index.html
        try_files $uri $uri/ /index.html;

        # Optional basic auth restriction
        # auth_basic "Restricted";
        # auth_basic_user_file /etc/nginx/.htpasswd;
    }
}

Replace this script with whatever you need for your particular hosting environment.

You probably want to configure your server to only respond POST requests from GitHub's public IP addresses, found on the webhooks settings page.

Dependencies

Here's a sample script to install the approriate dependencies on an Ubuntu server:

#!/bin/sh

# Install node and depencencies
sudo apt-get update -y
sudo apt-get install python-software-properties python g++ make -y
# On Ubuntu 12.10 and greater, add-apt-repository is provided by the software-properties-common package
#sudo apt-get install software-properties-common -y
sudo add-apt-repository ppa:chris-lea/node.js -y
sudo apt-get update -y
sudo apt-get install nodejs -y

# Forever to keep server running
sudo npm install -g forever

# Git
sudo apt-get install git -y

# Ruby
sudo apt-get install ruby1.8 -y
sudo apt-get install rubygems -y

# Jekyll
sudo gem install jekyll --version "0.12.0"
sudo gem install rdiscount -- version "1.6.8"
sudo gem install json --version "1.6.1"

# Nginx for static content
sudo apt-get install nginx -y

jekyll-hook's People

Watchers

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