<h2 id="how-it-works">How it works</h2>
<p><a href="https://docs.gitlab.com/ee/user/project/pages/"
class="uri">https://docs.gitlab.com/ee/user/project/pages/</a></p>
<blockquote>
<p>GitLab always deploys your website from a specific folder called
public in your repository. To deploy your site, GitLab uses its built-in
tool called GitLab CI/CD to build your site and publish it to the GitLab
Pages server. The sequence of scripts that GitLab CI/CD runs to
accomplish this task is created from a file named .gitlab-ci.yml, which
you can create and modify. A specific job called pages in the
configuration file makes GitLab aware that you're deploying a GitLab
Pages website.</p>
</blockquote>
<h3 id="overview-of-steps">Overview of Steps</h3>
<ul>
<li>The end state has to be a directory named public that contains the
site contents</li>
<li>Optionally, run a build process in a container to create the
contents of the <code>public</code> directory</li>
<li>There has to be a <code>pages</code> declaration in
.gitlab-ci.yml</li>
</ul>
<h2 id="example-1">Example 1</h2>
<h3 id="simple-demo">simple demo</h3>
<ul>
<li>Create the Git repo and site content</li>
<li>Go to gitlab and create new Gitlab repo</li>
<li>Clone it to your workstation</li>
<li>Add public folder with site files</li>
<li>add .gitlab-ci.yml</li>
<li>Commit and push</li>
</ul>
<pre class="bash"><code>git clone git@gitlab.com:norrist/simple_pages_demo.git
cd simple_pages_demo/
mkdir public
echo &quot;Hello World&quot; &gt; public/index.html
git add public/
vim  .gitlab-ci.yml
git add .gitlab-ci.yml
git commit -am &quot;new page&quot;
git push</code></pre>
<h4 id="gitlab-ci.yml">.gitlab-ci.yml</h4>
<pre class="yaml"><code>pages:
  stage: deploy
  script:
    - echo
  artifacts:
    paths:
      - public</code></pre>
<h3 id="pages-settings">Pages settings</h3>
<ul>
<li>Menu on left, Settings, Pages</li>
<li>Your pages are served under:</li>
</ul>
<h2 id="example-2">Example 2</h2>
<h3 id="docs.norrist.xyz">docs.norrist.xyz</h3>
<ul>
<li>Combine my HPR show notes into a single page</li>
<li>Custom Domain
<ul>
<li>Verified with TXT record</li>
</ul></li>
</ul>
<h4 id="gitlab-ci.yml-1">.gitlab-ci.yml</h4>
<pre class="yml"><code>image: &quot;debian&quot;
before_script:
    - apt-get update
    - apt-get install -y  pandoc

stages:
- build
pages:
  stage: build
  script:
    - bash build_html.sh
  artifacts:
    paths:
      - public</code></pre>
<pre class="bash"><code>set -euo pipefail
IFS=$&#39;\n\t&#39;
mkdir -pv public
for MD in $(ls *md)
    do
    echo
    # echo &quot;---&quot;
    # echo
    # echo &quot;#&quot; $MD
    echo
    echo &quot;---&quot;
    echo
    cat $MD
done    \
|pandoc \
-H markdown.header \
-B body.header \
--toc \
--toc-depth=1 \
-f gfm \
-t html \
-o public/index.html</code></pre>
<h2 id="example-3">Example 3</h2>
<h3 id="hpr-static">HPR static</h3>
<ul>
<li>Build the new HPR static site</li>
</ul>
<h4 id="gitlab-ci.yml-2">.gitlab-ci.yml</h4>
<pre class="yaml"><code>services:
  - mariadb
variables:
  MYSQL_DATABASE: hpr_hpr
  MYSQL_ROOT_PASSWORD: mysql

connect:
  stage: .pre
  image: mysql
  script:
  - echo &quot;SELECT &#39;OK&#39;;&quot; | mysql --user=root --password=&quot;$MYSQL_ROOT_PASSWORD&quot; --host=mariadb &quot;$MYSQL_DATABASE&quot;

pages:
  image: debian
  before_script:
      - apt update
      - apt -y install libgetopt-complete-perl libmemory-usage-perl libconfig-std-perl libtemplate-perl libtemplate-plugin-dbi-perl libclass-dbi-perl libtie-dbi-perl libdbd-mysql-perl  libdate-calc-perl
      - apt -y install curl mariadb-client git
      - curl -o hpr.sql http://hackerpublicradio.org/hpr.sql
      - mysql --user=root --host=mariadb &quot;$MYSQL_DATABASE&quot; --password=&quot;$MYSQL_ROOT_PASSWORD&quot;  &lt; hpr.sql

  stage: build
  script:
    - git clone https://gitlab.com/roan.horning/hpr_generator.git
    - cd hpr_generator
    - git apply ../mysql_settings.patch
    - grep &quot;database\|user\|driver\|password&quot; site.cfg
    - ./site-generator --all
    - mv -v public_html ../public

  artifacts:
    paths:
      - public
</code></pre>
<h3 id="site.cfg-patch">site.cfg Patch</h3>
<pre class="patch"><code>diff --git a/site.cfg b/site.cfg
index aefadb2..0243d27 100644
--- a/site.cfg
+++ b/site.cfg
@@ -8,10 +8,10 @@
 #user:        (not used - leave blank)
 #password:    (not used - leave blank)
 # Configuration settings for MySQL
-#database: mysql
-#driver: dbi:mysql:database=hpr_hpr:hostname=localhost
-#user: hpr-generator  (Suggested user with read-only privileges)
-#password: *********  (Password for user)
+database: mysql
+driver: dbi:mysql:database=hpr_hpr:hostname=mariadb
+user: root
+password: mysql

 # Configure the location of the templates and the generated HTML
 [app_paths]
@@ -25,7 +25,7 @@ output_path: ./public_html
 [root_template]
 content: page.tpl.html
 #baseurl: OPTIONAL [i.e. file://&lt;full path to local website directory&gt;]
-baseurl: file:///home/roan/Development/hpr/website/hpr_generator/public_html/
+baseurl: https://norrist.gitlab.io/hpr_generator_build/
 media_baseurl: https://archive.org/download/hpr$eps_id/

 # Configure the navigation menu and the content templates for each page</code></pre>
<h2 id="other-example-projects">Other Example Projects</h2>
<ul>
<li><a href="https://gitlab.com/pages"
class="uri">https://gitlab.com/pages</a></li>
<li>Hugo, Jekyll, Plain HTML, ...</li>
<li>Fork or just Copy</li>
</ul>
<h3 id="common-frustrations">Common Frustrations</h3>
<ul>
<li>Waiting on builds during debugging.</li>
<li>Having to push to CICD instead of running local</li>
</ul>
<h2 id="links">Links</h2>
<p><strong>HPR Generator</strong> - <a
href="https://repo.anhonesthost.net/rho_n/hpr_generator"
class="uri">https://repo.anhonesthost.net/rho_n/hpr_generator</a></p>
<table>
<colgroup>
<col style="width: 50%" />
<col style="width: 50%" />
</colgroup>
<thead>
<tr class="header">
<th>Gitlab Example Repo</th>
<th>Gitlab pages URL</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><a href="https://gitlab.com/norrist/simple_pages_demo"
class="uri">https://gitlab.com/norrist/simple_pages_demo</a></td>
<td><a href="https://norrist.gitlab.io/simple_pages_demo/"
class="uri">https://norrist.gitlab.io/simple_pages_demo/</a></td>
</tr>
<tr class="even">
<td><a href="https://gitlab.com/norrist/docs.norrist.xyz"
class="uri">https://gitlab.com/norrist/docs.norrist.xyz</a></td>
<td><a href="https://docs.norrist.xyz/"
class="uri">https://docs.norrist.xyz/</a></td>
</tr>
<tr class="odd">
<td><a href="https://gitlab.com/norrist/hpr_generator_build"
class="uri">https://gitlab.com/norrist/hpr_generator_build</a></td>
<td><a href="https://norrist.gitlab.io/hpr_generator_build/"
class="uri">https://norrist.gitlab.io/hpr_generator_build/</a></td>
</tr>
</tbody>
</table>
