blog/_posts/2021-02-21-an-alternative-t...

2.9 KiB

title tags updated description
An alternative to GitHub Pages
tutorial
hosting
gitlab
github
github-pages
2021-09-13 14:07:00 A DIY alternastive to GitHub and GitLab pages

Following what I have written in a [previous post]({% post_url 2021-02-17-new-hosting %}.html) I present you a DIY alternative to GitHub and GitLab pages.

I created a docs. virual host in Apache. Each repository documentation is contained in a distinct directory under that domain (and directory). For example md-toc is under docs.franco.net.eu.org/md-toc/

The first time you set up the pages do the following:

  1. create the bare repository like in the [previous post]({% post_url 2021-02-17-new-hosting %}.html)

  2. change the default branch in the HEAD file from ref: refs/heads/master to ref: refs/heads/docs

  3. mkdir the destination directory

  4. create a new executable file in hooks/post-receive, like this:

    #!/usr/bin/bash -l
    #
    # The MIT License (MIT)
    #
    # Copyright (c) 2008-present Tom Preston-Werner and Jekyll contributors
    #               2021 Franco Masotti
    #
    # Permission is hereby granted, free of charge, to any person obtaining a copy
    # of this software and associated documentation files (the "Software"), to deal
    # in the Software without restriction, including without limitation the rights
    # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    # copies of the Software, and to permit persons to whom the Software is
    # furnished to do so, subject to the following conditions:
    #
    # The above copyright notice and this permission notice shall be included in all
    # copies or substantial portions of the Software.
    #
    # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    # SOFTWARE.
    
    TMP_GIT_CLONE=""${HOME}"/tmp/myrepo"
    PUBLIC_WWW='/var/www/docs.franco.net.eu.org/myrepo'
    
    git clone "${GIT_DIR}" "${TMP_GIT_CLONE}"
    rm -rf "${PUBLIC_WWW}"/*
    cp -aR "${TMP_GIT_CLONE}"/* "${PUBLIC_WWW}"
    rm -rf "${TMP_GIT_CLONE}"
    exit
    

As you can see these instructions are not very different from this blog post from GitLab.

Finally follow the usual standards, starting from this version.