From 4488d6b4ff0084449289f33993e308e5e6e80d96 Mon Sep 17 00:00:00 2001 From: Franco Masotti Date: Sun, 21 Feb 2021 19:05:24 +0100 Subject: [PATCH] Added new post. --- ...21-02-21-an-alternative-to-github-pages.md | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 _posts/2021-02-21-an-alternative-to-github-pages.md diff --git a/_posts/2021-02-21-an-alternative-to-github-pages.md b/_posts/2021-02-21-an-alternative-to-github-pages.md new file mode 100644 index 0000000..6c28e16 --- /dev/null +++ b/_posts/2021-02-21-an-alternative-to-github-pages.md @@ -0,0 +1,61 @@ +--- +title: An alternative to GitHub Pages +tags: [hosting, gitlab, github, github-pages] +updated: 2021-02-21 19:04 +description: 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](https://software.frnmst.duckdns.org/frnmst/md-toc/) is under [docs.frnmst.duckdns.org/md-toc/](https://docs.frnmst.duckdns.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.frnmst.duckdns.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](https://about.gitlab.com/blog/2016/04/07/gitlab-pages-setup/#add-gitlab-ci). + +Finally follow the usual standards, starting from +[this version](https://software.frnmst.duckdns.org/frnmst/fpydocs/raw/commit/bd60eb940cb3d82654e3085e7d51ddffb69cc00f/docs/workflow_common.rst).