Skip to content

Flow EasyApp (build, depoy) Gogs@gh pages Github@gh pages

Bao Trinh edited this page Jan 22, 2017 · 4 revisions

How to setup configuration for EasyWeb websites to deploy

see Deployment overview, link

git-hook-listener also run on https://demo.easywebhub.com

  1. Add Demo webhook Url cho repository vừa tạo, https://demo.easywebhub.com/web-hook, giống nhau cho tất cả repositories
  • call setup webhook trên gogs cho repository vừa tạo của user
  • image
  1. Create new repository on github.com and point sub-domain to it
  • using common easyweb account, ewh-support, pass: đã share
  • create sub-domain and point to this repository using Cloudflare
  1. add config vào trong git-hook-listener, nằm trên demo.easywebhub.com
  • Manual or automatic call API to add config: phương bổ sung
  • use github repository created on step 2, and sample config, see image
  1. Update info to Stagging and Production section of EasyWeb account
  • Do manual by calling API (check first)
  • automatically update

Overview flow

EasyApp               Gogs(private git server)              Git-hook-listener                               Github
build and depoly   -> 
                      private repo got update
                      follow repo's webhook config  ->  
                                                        got POST (push event info) from gogs
                                                        clone or pull update from gogs repos  
                                                        follow config ('then' section) push data github
                                                                                                   ->   
                                                                                     received update data in gh-pages branch
                                                                                         github gh-page site updated 

Config

config nginx

  • Tạo virtual host git-hook-listener.easywebhub.com -> port của git-hook-listener app
{
    listen 80;

    server_name git-hook-listener.easywebhub.com;

    location / {
        proxy_pass http://127.0.0.1:8001; // port theo port dang config trong git-hook-listener
    }
}

gogs

  • Create webhook setting
url: 'https://git-hook-listener.easywebhub.com/web-hook' 
secret: match secret in git-hook-listener config

git-hook-listener config

  • hiện tại git-hook-listener se ignore tất cả command result error trong 'then' section và thực hiện command tiep theo
{
            "repoUrl": "http://qq:d65f1c188efa497d2e9d28f1ea83b42625b574b1ec7e98b02db1404a9882faf2@source.easywebhub.com/qq/test-pull.git", // gogs repo http url with username and password
            "branch": "gh-pages", // branch in push event send from gogs, use for matching gogs's event -> config
            "cloneBranch": "gh-pages", // branch git-hook-listener will clone (only affect first time clone) cac request sau la pull, cloneBranch không có tác dụng
            "path": "repositories/test-pull",
            "args": [],
            "then": [
	        // this command will only work first time, if change url use set-url command
                {
                    "command": "git",
                    "args": [
                        "remote", "add", "github", "https://thayUserNameVoDay:thayPassVoDay@github.com/nemesisqp/test-pull-dst.git"
                    ],
                    "options": {env: process.env, cwd: "repositories/test-pull"}
                },
                // push to gh-pages github remote
                {
                    "command": "git",
                    "args": [
                        "push", "--force", "github", "gh-pages"
                    ],
                    "options": {env: process.env, cwd: "repositories/test-pull"}
                }
            ]
        }