[virttools-planet PATCH 2/4] Introduce use of GitLab CI for publishing to GitLab Pages

Daniel P. Berrangé berrange at redhat.com
Tue Mar 31 10:08:51 UTC 2020


To publish to GitLab pages, all that is required is to provide a CI job
that creates files in a directory called "public" and list that as an
artifact.

When the CI job completes, the website is immediately available at the
URL  https://username.gitlab.io/reponame. This makes it much easier to
preview changes to the site than with OpenShift apps.

Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
---
 .gitlab-ci.yml                                |  14 ++++++++++++
 README.md                                     |  20 +++++++-----------
 updater/planet-cache.py => planet-cache.py    |   0
 updater/planet.py => planet.py                |   0
 {updater/planet => planet}/__init__.py        |   0
 {updater/planet => planet}/atomstyler.py      |   0
 {updater/planet => planet}/cache.py           |   0
 .../compat_logging/__init__.py                |   0
 .../compat_logging/config.py                  |   0
 .../compat_logging/handlers.py                |   0
 {updater/planet => planet}/feedparser.py      |   0
 {updater/planet => planet}/htmltmpl.py        |   0
 {updater/planet => planet}/sanitize.py        |   0
 {updater/planet => planet}/tests/__init__.py  |   0
 .../planet => planet}/tests/test_channel.py   |   0
 {updater/planet => planet}/tests/test_main.py |   0
 .../planet => planet}/tests/test_sanitize.py  |   0
 {updater/planet => planet}/timeoutsocket.py   |   0
 .../images/alexbennee.jpeg                    | Bin
 .../virt-tools => public}/images/berrange.png | Bin
 .../virt-tools => public}/images/cole.png     | Bin
 .../images/ehabkost.jpeg                      | Bin
 .../images/header-bg.png                      | Bin
 .../virt-tools => public}/images/kashyap.jpeg | Bin
 .../virt-tools => public}/images/logo.png     | Bin
 .../virt-tools => public}/images/logo.xcf     | Bin
 .../virt-tools => public}/images/otubo.png    | Bin
 .../virt-tools => public}/images/qemu.png     | Bin
 .../virt-tools => public}/images/rjones.jpeg  | Bin
 .../virt-tools => public}/images/sgarzare.png | Bin
 .../virt-tools => public}/images/teuf.png     | Bin
 .../images/thomashuth.png                     | Bin
 .../virt-tools => public}/images/ybettan.png  | Bin
 .../virt-tools => public}/images/zeenix.png   | Bin
 updater/app.py                                |  18 ----------------
 .../virt-tools => virt-tools}/atom.xml.tmpl   |   0
 .../basic/index.html.tmpl                     |   7 +++---
 .../basic/style.css.tmpl                      |   0
 {updater/virt-tools => virt-tools}/config.ini |   4 ++--
 .../foafroll.xml.tmpl                         |   0
 .../virt-tools => virt-tools}/opml.xml.tmpl   |   0
 .../virt-tools => virt-tools}/rss10.xml.tmpl  |   0
 .../virt-tools => virt-tools}/rss20.xml.tmpl  |   0
 43 files changed, 27 insertions(+), 36 deletions(-)
 create mode 100644 .gitlab-ci.yml
 rename updater/planet-cache.py => planet-cache.py (100%)
 rename updater/planet.py => planet.py (100%)
 rename {updater/planet => planet}/__init__.py (100%)
 rename {updater/planet => planet}/atomstyler.py (100%)
 rename {updater/planet => planet}/cache.py (100%)
 rename {updater/planet => planet}/compat_logging/__init__.py (100%)
 rename {updater/planet => planet}/compat_logging/config.py (100%)
 rename {updater/planet => planet}/compat_logging/handlers.py (100%)
 rename {updater/planet => planet}/feedparser.py (100%)
 rename {updater/planet => planet}/htmltmpl.py (100%)
 rename {updater/planet => planet}/sanitize.py (100%)
 rename {updater/planet => planet}/tests/__init__.py (100%)
 rename {updater/planet => planet}/tests/test_channel.py (100%)
 rename {updater/planet => planet}/tests/test_main.py (100%)
 rename {updater/planet => planet}/tests/test_sanitize.py (100%)
 rename {updater/planet => planet}/timeoutsocket.py (100%)
 rename {updater/virt-tools => public}/images/alexbennee.jpeg (100%)
 rename {updater/virt-tools => public}/images/berrange.png (100%)
 rename {updater/virt-tools => public}/images/cole.png (100%)
 rename {updater/virt-tools => public}/images/ehabkost.jpeg (100%)
 rename {updater/virt-tools => public}/images/header-bg.png (100%)
 rename {updater/virt-tools => public}/images/kashyap.jpeg (100%)
 rename {updater/virt-tools => public}/images/logo.png (100%)
 rename {updater/virt-tools => public}/images/logo.xcf (100%)
 rename {updater/virt-tools => public}/images/otubo.png (100%)
 rename {updater/virt-tools => public}/images/qemu.png (100%)
 rename {updater/virt-tools => public}/images/rjones.jpeg (100%)
 rename {updater/virt-tools => public}/images/sgarzare.png (100%)
 rename {updater/virt-tools => public}/images/teuf.png (100%)
 rename {updater/virt-tools => public}/images/thomashuth.png (100%)
 rename {updater/virt-tools => public}/images/ybettan.png (100%)
 rename {updater/virt-tools => public}/images/zeenix.png (100%)
 delete mode 100755 updater/app.py
 rename {updater/virt-tools => virt-tools}/atom.xml.tmpl (100%)
 rename {updater/virt-tools => virt-tools}/basic/index.html.tmpl (91%)
 rename {updater/virt-tools => virt-tools}/basic/style.css.tmpl (100%)
 rename {updater/virt-tools => virt-tools}/config.ini (98%)
 rename {updater/virt-tools => virt-tools}/foafroll.xml.tmpl (100%)
 rename {updater/virt-tools => virt-tools}/opml.xml.tmpl (100%)
 rename {updater/virt-tools => virt-tools}/rss10.xml.tmpl (100%)
 rename {updater/virt-tools => virt-tools}/rss20.xml.tmpl (100%)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..cfc6bf6
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,14 @@
+
+image: centos:7
+
+pages:
+  stage: build
+  cache:
+    paths:
+      - cache/
+    key: "$CI_JOB_NAME"
+  script:
+    - python2 planet.py virt-tools/config.ini
+  artifacts:
+    paths:
+      - public
diff --git a/README.md b/README.md
index 68ae162..034029a 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@ This directory contains content / configuration for managing
 
 How to add your blog
 --------------------
-Add a config.ini section for your blog to `updater/virt-tools/config.ini`:
+Add a config.ini section for your blog to `virt-tools/config.ini`:
 
 ```
   [https://example.org/my/blog/feed/]
@@ -21,8 +21,7 @@ Add a config.ini section for your blog to `updater/virt-tools/config.ini`:
 Where `face` (logo image filename), `facewidth` (logo image width in pixels),
 and `faceheight` (logo image height in pixels) are optional attributes that
 describe the logo image associated with your blog.  Remember to add your image
-file into the `updater/virt-tools/images/` directory if you wish to use an
-image.
+file into the `public/images/` directory if you wish to use an image.
 
 Please send a patch email to `libvir-list at redhat.com`:
 
@@ -34,14 +33,11 @@ Please send a patch email to `libvir-list at redhat.com`:
 How to run the site
 -------------------
 
-The site is setup to run under OpenShift
+The site is intended to be published with GitLab Pages
 
-Initial load can be done with
+Upon pushing changes to the GitLab repository, CI rules will automatically
+build the site and publish the result to the repository's GitLab Pages
+site.
 
-```
-  oc process -f openshift/templates/virttools-planet.json  | oc create -f -
-```
-
-Updates to the OpenShift config are manually activated using `oc replace`.
-
-Updates to the content itself are automatically propagated via a planet hook.
+A scheduled CI pipeline should also be configured to run once an hour to
+refresh the blog feeds.
diff --git a/updater/planet-cache.py b/planet-cache.py
similarity index 100%
rename from updater/planet-cache.py
rename to planet-cache.py
diff --git a/updater/planet.py b/planet.py
similarity index 100%
rename from updater/planet.py
rename to planet.py
diff --git a/updater/planet/__init__.py b/planet/__init__.py
similarity index 100%
rename from updater/planet/__init__.py
rename to planet/__init__.py
diff --git a/updater/planet/atomstyler.py b/planet/atomstyler.py
similarity index 100%
rename from updater/planet/atomstyler.py
rename to planet/atomstyler.py
diff --git a/updater/planet/cache.py b/planet/cache.py
similarity index 100%
rename from updater/planet/cache.py
rename to planet/cache.py
diff --git a/updater/planet/compat_logging/__init__.py b/planet/compat_logging/__init__.py
similarity index 100%
rename from updater/planet/compat_logging/__init__.py
rename to planet/compat_logging/__init__.py
diff --git a/updater/planet/compat_logging/config.py b/planet/compat_logging/config.py
similarity index 100%
rename from updater/planet/compat_logging/config.py
rename to planet/compat_logging/config.py
diff --git a/updater/planet/compat_logging/handlers.py b/planet/compat_logging/handlers.py
similarity index 100%
rename from updater/planet/compat_logging/handlers.py
rename to planet/compat_logging/handlers.py
diff --git a/updater/planet/feedparser.py b/planet/feedparser.py
similarity index 100%
rename from updater/planet/feedparser.py
rename to planet/feedparser.py
diff --git a/updater/planet/htmltmpl.py b/planet/htmltmpl.py
similarity index 100%
rename from updater/planet/htmltmpl.py
rename to planet/htmltmpl.py
diff --git a/updater/planet/sanitize.py b/planet/sanitize.py
similarity index 100%
rename from updater/planet/sanitize.py
rename to planet/sanitize.py
diff --git a/updater/planet/tests/__init__.py b/planet/tests/__init__.py
similarity index 100%
rename from updater/planet/tests/__init__.py
rename to planet/tests/__init__.py
diff --git a/updater/planet/tests/test_channel.py b/planet/tests/test_channel.py
similarity index 100%
rename from updater/planet/tests/test_channel.py
rename to planet/tests/test_channel.py
diff --git a/updater/planet/tests/test_main.py b/planet/tests/test_main.py
similarity index 100%
rename from updater/planet/tests/test_main.py
rename to planet/tests/test_main.py
diff --git a/updater/planet/tests/test_sanitize.py b/planet/tests/test_sanitize.py
similarity index 100%
rename from updater/planet/tests/test_sanitize.py
rename to planet/tests/test_sanitize.py
diff --git a/updater/planet/timeoutsocket.py b/planet/timeoutsocket.py
similarity index 100%
rename from updater/planet/timeoutsocket.py
rename to planet/timeoutsocket.py
diff --git a/updater/virt-tools/images/alexbennee.jpeg b/public/images/alexbennee.jpeg
similarity index 100%
rename from updater/virt-tools/images/alexbennee.jpeg
rename to public/images/alexbennee.jpeg
diff --git a/updater/virt-tools/images/berrange.png b/public/images/berrange.png
similarity index 100%
rename from updater/virt-tools/images/berrange.png
rename to public/images/berrange.png
diff --git a/updater/virt-tools/images/cole.png b/public/images/cole.png
similarity index 100%
rename from updater/virt-tools/images/cole.png
rename to public/images/cole.png
diff --git a/updater/virt-tools/images/ehabkost.jpeg b/public/images/ehabkost.jpeg
similarity index 100%
rename from updater/virt-tools/images/ehabkost.jpeg
rename to public/images/ehabkost.jpeg
diff --git a/updater/virt-tools/images/header-bg.png b/public/images/header-bg.png
similarity index 100%
rename from updater/virt-tools/images/header-bg.png
rename to public/images/header-bg.png
diff --git a/updater/virt-tools/images/kashyap.jpeg b/public/images/kashyap.jpeg
similarity index 100%
rename from updater/virt-tools/images/kashyap.jpeg
rename to public/images/kashyap.jpeg
diff --git a/updater/virt-tools/images/logo.png b/public/images/logo.png
similarity index 100%
rename from updater/virt-tools/images/logo.png
rename to public/images/logo.png
diff --git a/updater/virt-tools/images/logo.xcf b/public/images/logo.xcf
similarity index 100%
rename from updater/virt-tools/images/logo.xcf
rename to public/images/logo.xcf
diff --git a/updater/virt-tools/images/otubo.png b/public/images/otubo.png
similarity index 100%
rename from updater/virt-tools/images/otubo.png
rename to public/images/otubo.png
diff --git a/updater/virt-tools/images/qemu.png b/public/images/qemu.png
similarity index 100%
rename from updater/virt-tools/images/qemu.png
rename to public/images/qemu.png
diff --git a/updater/virt-tools/images/rjones.jpeg b/public/images/rjones.jpeg
similarity index 100%
rename from updater/virt-tools/images/rjones.jpeg
rename to public/images/rjones.jpeg
diff --git a/updater/virt-tools/images/sgarzare.png b/public/images/sgarzare.png
similarity index 100%
rename from updater/virt-tools/images/sgarzare.png
rename to public/images/sgarzare.png
diff --git a/updater/virt-tools/images/teuf.png b/public/images/teuf.png
similarity index 100%
rename from updater/virt-tools/images/teuf.png
rename to public/images/teuf.png
diff --git a/updater/virt-tools/images/thomashuth.png b/public/images/thomashuth.png
similarity index 100%
rename from updater/virt-tools/images/thomashuth.png
rename to public/images/thomashuth.png
diff --git a/updater/virt-tools/images/ybettan.png b/public/images/ybettan.png
similarity index 100%
rename from updater/virt-tools/images/ybettan.png
rename to public/images/ybettan.png
diff --git a/updater/virt-tools/images/zeenix.png b/public/images/zeenix.png
similarity index 100%
rename from updater/virt-tools/images/zeenix.png
rename to public/images/zeenix.png
diff --git a/updater/app.py b/updater/app.py
deleted file mode 100755
index 03b086f..0000000
--- a/updater/app.py
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/usr/bin/python
-
-import os
-import time
-
-update = "./planet.py ./virt-tools/config.ini"
-
-os.system("rsync -av virt-tools/images/ /opt/app-root/web/images/")
-
-while True:
-    ret = os.system(update)
-    rv = ret >> 8
-    if rv != 0:
-        print "Update failed, retrying in 60 seconds"
-        time.sleep(60)
-    else:
-        print "Update succeeded, refreshing in 30 minutes"
-        time.sleep(30*60)
diff --git a/updater/virt-tools/atom.xml.tmpl b/virt-tools/atom.xml.tmpl
similarity index 100%
rename from updater/virt-tools/atom.xml.tmpl
rename to virt-tools/atom.xml.tmpl
diff --git a/updater/virt-tools/basic/index.html.tmpl b/virt-tools/basic/index.html.tmpl
similarity index 91%
rename from updater/virt-tools/basic/index.html.tmpl
rename to virt-tools/basic/index.html.tmpl
index d26aba0..93eb88f 100644
--- a/updater/virt-tools/basic/index.html.tmpl
+++ b/virt-tools/basic/index.html.tmpl
@@ -23,7 +23,7 @@
 	<TMPL_LOOP Channels>
 	  <li><a href="<TMPL_VAR link ESCAPE="HTML">" title="<TMPL_VAR title ESCAPE="HTML">"><TMPL_VAR name></a> <a href="<TMPL_VAR url ESCAPE="HTML">">(feed)</a></li>
 	</TMPL_LOOP>
-        <li><a href="https://libvirt.org/git/?p=virttools-planet.git;a=blob;f=README">Add your blog!</a></li>
+        <li><a href="https://gitlab.com/libvirt/virttools-planet/-/blob/master/README.md">Add your blog!</a></li>
       </ul>
     </div>
 
@@ -73,9 +73,8 @@
   <div id="planetfooter">
     <a href="http://www.planetplanet.org/">Powered by Planet!</a><br>
     <em>Last updated: <TMPL_VAR date></em>
-    <a href="https://www.openshift.com/" title="Powered by OpenShift Online"><br>
-      <img alt="Powered by OpenShift Online" src="https://www.openshift.com/images/logos/powered_by_openshift_reverse.png">
-    </a>
+    &emdash;
+    <a href="https://gitlab.com/libvirt/virttools-planet/-/blob/master/virt-tools/basic/index.html.tmpl" title="Edit this page">Edit this page</a>
   </div>
 
 <script type="text/javascript">
diff --git a/updater/virt-tools/basic/style.css.tmpl b/virt-tools/basic/style.css.tmpl
similarity index 100%
rename from updater/virt-tools/basic/style.css.tmpl
rename to virt-tools/basic/style.css.tmpl
diff --git a/updater/virt-tools/config.ini b/virt-tools/config.ini
similarity index 98%
rename from updater/virt-tools/config.ini
rename to virt-tools/config.ini
index 6265e6f..eff9a20 100644
--- a/updater/virt-tools/config.ini
+++ b/virt-tools/config.ini
@@ -14,7 +14,7 @@ owner_email = berrange at redhat.com
 # cache_directory: Where cached feeds are stored
 # new_feed_items: Number of items to take from new feeds
 # log_level: One of DEBUG, INFO, WARNING, ERROR or CRITICAL
-cache_directory = /opt/app-root/cache
+cache_directory = cache
 new_feed_items = 5
 log_level = DEBUG
 
@@ -33,7 +33,7 @@ template_files = virt-tools/basic/index.html.tmpl virt-tools/atom.xml.tmpl virt-
 # locale: locale to use for (e.g.) strings in dates, default is taken from your
 #         system. You can specify more locales separated by ':', planet will
 #         use the first available one
-output_dir = /opt/app-root/web
+output_dir = public
 items_per_page = 30
 days_per_page = 0
 date_format = %B %d, %Y %I:%M %p
diff --git a/updater/virt-tools/foafroll.xml.tmpl b/virt-tools/foafroll.xml.tmpl
similarity index 100%
rename from updater/virt-tools/foafroll.xml.tmpl
rename to virt-tools/foafroll.xml.tmpl
diff --git a/updater/virt-tools/opml.xml.tmpl b/virt-tools/opml.xml.tmpl
similarity index 100%
rename from updater/virt-tools/opml.xml.tmpl
rename to virt-tools/opml.xml.tmpl
diff --git a/updater/virt-tools/rss10.xml.tmpl b/virt-tools/rss10.xml.tmpl
similarity index 100%
rename from updater/virt-tools/rss10.xml.tmpl
rename to virt-tools/rss10.xml.tmpl
diff --git a/updater/virt-tools/rss20.xml.tmpl b/virt-tools/rss20.xml.tmpl
similarity index 100%
rename from updater/virt-tools/rss20.xml.tmpl
rename to virt-tools/rss20.xml.tmpl
-- 
2.24.1




More information about the libvir-list mailing list