[PATCH 1/4] gitlab-ci: Configure website build to be published via gitlab pages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Modify the build process of the web page to publish the contents of the
web page also via gitlab pages.

The current webpage job is renamed to 'website_prebuilt_env_legacy' but
preserves the naming of artifacts. This is needed to preserve the
current approach where libvirt.org is hosted from the old server by
pulling the artifacts.

New jobs are added, which use the new artifact naming scheme needed for
gitlab pages to host them.

Artifacts are named 'pages' and contain a 'public' directory now.

The new jobs are:

 - pages:
    - triggered on push to master

 - website_prebuilt_env:
    - triggered on any remaining trigger of 'gitlab_native_build_job_prebuilt_env'
      except for the push to master
    - artifact naming uses the new scheme
 - website_local_env:
    - triggered same way as gitlab_native_build_job_local_env
    - uses new naming scheme

Doing the above allows us to have gitlab pages coexist with the old
setup until etiher switching to gitlab pages completely (once the remote
redirects feature gets enabled for the main instance) or changing the
old server to pull data from the new job artifact location:

  https://gitlab.com/libvirt/libvirt/-/jobs/artifacts/master/download?job=pages

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 .gitlab-ci.yml | 86 +++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 81 insertions(+), 5 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 8bad761b32..6c7d54c311 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -78,7 +78,8 @@ include:
     - .cross_build_job
     - .gitlab_cross_build_job_local_env

-
+# LEGACY web page build
+#
 # This artifact published by this job is downloaded by libvirt.org to
 # be deployed to the web root:
 #    https://gitlab.com/libvirt/libvirt/-/jobs/artifacts/master/download?job=website
@@ -97,7 +98,7 @@ include:
     paths:
       - website

-website_prebuilt_env:
+website_prebuilt_env_legacy:
   extends:
     - .website_job
     - .gitlab_native_build_job_prebuilt_env
@@ -107,13 +108,88 @@ website_prebuilt_env:
   variables:
     NAME: almalinux-8

+
+# This job builds the website and publishes it in the following ways:
+# - 'pages'
+#   - publishing for gitlab pages
+#   - done only on push to the default branch
+# - 'website*'
+#   - for CI purposes
+#   - job name based on how it was invoked:
+#     - 'website_prebuilt_env'
+#       - when the CI runs on the container images build by the upstream libvirt project
+#     - 'website_local_env'
+#       - when run in locally-rebuilt environment
+#
+# The job exposes artifacts containing a directory named 'public'.
+#
+.pages_job:
+  script:
+    - source ci/jobs.sh
+    - run_website_build
+  after_script:
+    - test "$CI_JOB_STATUS" != "success" && exit 1;
+    - mv install/usr/share/doc/libvirt/html/ public
+  artifacts:
+    expose_as: 'pages'
+    name: 'pages'
+    paths:
+      - public
+
+pages:
+  extends:
+    - .pages_job
+  needs:
+    - job: x86_64-fedora-39-container
+      optional: true
+  variables:
+    NAME: fedora-39
+  stage: builds
+  image: $CI_REGISTRY/$RUN_UPSTREAM_NAMESPACE/libvirt/ci-$NAME:latest
+  before_script:
+    - cat /packages.txt
+  rules:
+    - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
+      when: on_success
+    - when: never
+
+website_prebuilt_env:
+  extends:
+    - .pages_job
+    - .gitlab_native_build_job_prebuilt_env
+  needs:
+    - job: x86_64-fedora-39-container
+      optional: true
+  variables:
+    NAME: fedora-39
+  rules:
+    # forks: pushes to a branch when a pipeline run in upstream env is explicitly requested
+    - if: '$CI_PROJECT_NAMESPACE != $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE == "push" && $RUN_PIPELINE_UPSTREAM_ENV'
+      when: on_success
+
+    # upstream: other web/api/scheduled pipelines targeting the default branch
+    - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/ && $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH'
+      when: on_success
+
+    # upstream+forks: merge requests targeting the default branch, without CI changes
+    - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH'
+      changes:
+        - ci/gitlab/container-templates.yml
+        - ci/containers/$NAME.Dockerfile
+      when: never
+    - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH'
+      when: on_success
+
+    # upstream+forks: that's all folks
+    - when: never
+
 website_local_env:
   extends:
-    - .website_job
+    - .pages_job
     - .gitlab_native_build_job_local_env
   variables:
-    IMAGE: docker.io/library/almalinux:8
-    NAME: almalinux-8
+    IMAGE: registry.fedoraproject.org/fedora:39
+    NAME: fedora-39


 .codestyle_job:
-- 
2.43.0
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux