Commit a72e91d3 authored by Marcus M. Scheunemann's avatar Marcus M. Scheunemann

typos

parent 63be8044
Pipeline #41677859 passed with stage
in 1 minute and 51 seconds
......@@ -5,16 +5,17 @@ Automatically deploy your Pelican website using Gitlab
:modified: 2018-12-22 21:28
:tags: git, CI, gitlab, runner, variables, automatic, deploy
:category: dev/null
:summary: This article describes step by step how to set up jobs with `Gitlab <https://gitlab.com/>`__'s continous itnegration (CI) tools for building and deploying a static website generated with `Pelican <https://github.com/getpelican/pelican>`__. The source of the website needs to be hosted (publically or privatley) on `Gitlab <https://gitlab.com/scheunemann/website>`__. As an example, this web site is the result of the current `master branch <https://gitlab.com/scheunemann/website/tree/master>`__. For each change on a remote branch on Gitlab, the website gets build as a test. If there is a change on the branch "master", an additional job deploys the webpage to an external web server using the file transfer protocol (FTP).
:summary: This article describes step by step how to set up jobs with `Gitlab <https://gitlab.com/>`__'s continuous integration (CI) tools for building and deploying a static website generated with `Pelican <https://github.com/getpelican/pelican>`__.
The source of the website needs to be hosted (publically or privately) on `Gitlab <https://gitlab.com/scheunemann/website>`__. As an example, this page is the result of the current `master branch <https://gitlab.com/scheunemann/website/tree/master/content/articles/2018-12-22-auto-deploy-static-pelican-website-with-gitlab/main.rst>`__. For each change on a remote branch on Gitlab, the website gets build as a test. If there is a change on the branch "master", an additional job deploys the website to an external web server using the file transfer protocol (FTP).
.. role:: raw-html(raw)
:format: html
This article describes step by step how to set up jobs with `Gitlab <https://gitlab.com/>`__'s continous integration (CI) tools for building and deploying a static website generated with `Pelican <https://github.com/getpelican/pelican>`__.
The source of the website needs to be hosted (publically or privatley) on `Gitlab <https://gitlab.com/scheunemann/website>`__.
This article describes step by step how to set up jobs with `Gitlab <https://gitlab.com/>`__'s continuous integration (CI) tools for building and deploying a static website generated with `Pelican <https://github.com/getpelican/pelican>`__.
The source of the website needs to be hosted (publically or privately) on `Gitlab <https://gitlab.com/scheunemann/website>`__.
As an example, this page is the result of the current `master branch <https://gitlab.com/scheunemann/website/tree/master/content/articles/2018-12-22-auto-deploy-static-pelican-website-with-gitlab/main.rst>`__.
For each change on a remote branch on Gitlab, the website gets build as a test. If there is a change on the branch "master", an additional job deploys the webpage to an external web server using the file transfer protocol (FTP).
For each change on a remote branch on Gitlab, the website gets build as a test. If there is a change on the branch "master", an additional job deploys the website to an external web server using the file transfer protocol (FTP).
Requirements
============
......@@ -23,7 +24,7 @@ Requirements
- basic Git knowledge
- a Gitlab account. CI tools for all open source projects are free, but there is also limited free access for private projects.
Set up continous integration (CI)
Set up continuous integration (CI)
=================================
We create a file called `.gitlab-ci.yml <https://mms.ai>`_ in the root directory of the repository. It describes what the runner has to do on changes in a branch on gitlab.
......@@ -31,7 +32,7 @@ We create a file called `.gitlab-ci.yml <https://mms.ai>`_ in the root directory
Preparing the build environment
-------------------------------
The file .gitlab-ci.yml starts with defining a docker image. I've chosen the latest ubuntu image ``ubuntu:latest`` just because of Ubuntu's popularity.
The file .gitlab-ci.yml starts with defining a docker image. I've chosen the latest Ubuntu image ``ubuntu:latest`` just because of Ubuntu's popularity.
.. code-block:: yaml
......@@ -52,11 +53,11 @@ The minimal ubuntu environment will need some packages in order to allow us to u
Before any job, the following happens:
1) updating ubuntu and installing `git` and `pip` (we need `git` for updating all submodules, e.g., themes and plugins, you can skip that if you don't use submodules)
1) updating Ubuntu and installing `git` and `pip` (we need `git` for updating all submodules, e.g., themes and plugins, you can skip that if you don't use submodules)
2) creating a virtual environment to allow for installing specific versions of Python packages independent of global system packages
3) installing all Python packages required by your website
Creating a job for buidling the website
Creating a job for building the website
---------------------------------------
We define a "job" called "build website" for building the pelican site. If the site gets build without errors, the job is successful. The line ``stage: build`` is optional.
......@@ -81,12 +82,12 @@ When the job is done successfully, i.e., the website was built, the sign changes
.. image:: {attach}job-build-website-passed.png
:alt: The job "Build website" is still running
Refer to the full output for the job `#139894076 <https://gitlab.com/scheunemann/website/-/jobs/139894076>`__ of the pipline `#41645760 <https://gitlab.com/scheunemann/website/pipelines/41645760>`__ for details.
Refer to the full output for the job `#139894076 <https://gitlab.com/scheunemann/website/-/jobs/139894076>`__ of the pipeline `#41645760 <https://gitlab.com/scheunemann/website/pipelines/41645760>`__ for details.
Deploying the built website with FTP
------------------------------------
If we change the master branch, the same job "build website" gets triggered. In addition, I want to deploy to webpage to an external webserver if the job "build website" was successful.
If we change the master branch, the same job "build website" gets triggered. In addition, I want to deploy to webpage to an external web server if the job "build website" was successful.
The additional job is called "deploy website".
......@@ -107,7 +108,7 @@ What's happening in "deploy website":
2) we define that this job gets triggered only in the branch "master"
3) we build the page with the "publishconf.py" settings
4) we install the client ``lftp``
5) lftp gets triggered so that the code is uploaded to an external webserver via ftp
5) lftp gets triggered so that the code is uploaded to an external web server via ftp
The commit and the job execution is shown in commit `32e8161e <https://gitlab.com/scheunemann/website/commit/32e8161e45b95751fbfbf7acd2db89e10418c93d>`_. Although both jobs are part of the ".gitlab-ci.yml", only one has been triggered as we pushed to the branch "article-auto-deploy" (i.e., not to the branch "master").
......@@ -124,7 +125,7 @@ In the following, all three executions after each commit are shown. Only when th
Setting up environment variables
--------------------------------
You will notice environment variables (e.g. `$FTP_PASS`) in the upper example. As the file .gitlab-ci.yml can be publically acessible in our repo, we don't want everybody to see our credentials for the server. I firstly set up a dedicated FTP user on my server. I'll then used the Gitlab feature "Settings :raw-html:`&rarr;` CI \ CD :raw-html:`&rarr;` Variables" for setting up variables as follows:
You will notice environment variables (e.g. `$FTP_PASS`) in the upper example. As the file .gitlab-ci.yml can be publically accessible in our repo, we don't want everybody to see our credentials for the server. I firstly set up a dedicated FTP user on my server. I'll then used the Gitlab feature "Settings :raw-html:`&rarr;` CI \ CD :raw-html:`&rarr;` Variables" for setting up variables as follows:
.. image:: {attach}set-environment-varibles-for-CI.png
:alt: Setting up environment variables to use in .gitlab-ci.yml
......@@ -144,10 +145,10 @@ Troubleshooting
Runner
------
We use Gitlab's Shared Runners for a quick start. They are enabled by default on newer gitlab versions. Check if they are enabled under "Settings :raw-html:`&rarr;` CI/CD :raw-html:`&rarr;` Runners". In the image belove, you see that the runner #44028 comes with docker pre-installed:
We use Gitlab's Shared Runners for a quick start. They are enabled by default on newer Gitlab versions. Check if they are enabled under "Settings :raw-html:`&rarr;` CI/CD :raw-html:`&rarr;` Runners". In the image belove, you see that the runner #44028 comes with docker pre-installed:
.. image:: {attach}select-shared-runner-gitlab.png
:alt: Select Shared Runners on gitlab
:alt: Select Shared Runners on Gitlab
More information
----------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment