Skip to content

Commit ba9d026

Browse files
Upgrade CD pipeline (#5022)
Description of changes: - update continuous delivery (CD) pipeline to download CI artifacts through the GitLab REST API - properly document and install all required dependencies of the CD pipeline - the new Ubuntu 24.04 runner comes with fewer pre-installed depdendencies - move action script to a self-contained shell script - simplify maintenance work with tools like shellcheck - print fully expanded shell commands before executing them to help diagnose issues with cloud services
2 parents df11a0e + 77f7ede commit ba9d026

File tree

3 files changed

+107
-59
lines changed

3 files changed

+107
-59
lines changed

.github/actions/deploy_docs/action.yml

Lines changed: 0 additions & 53 deletions
This file was deleted.

.github/workflows/deploy.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,27 @@ name: deploy
22

33
on:
44
schedule:
5-
- cron: '0 7 * * *'
5+
- cron: '0 7 * * *' # daily at 07:00 AM
66

77
permissions:
88
contents: read # to fetch code (actions/checkout)
99

1010
jobs:
1111
deploy_docs:
12-
runs-on: ubuntu-22.04
13-
if: github.repository == 'espressomd/espresso'
12+
runs-on: ubuntu-24.04
13+
if: ${{ github.repository == 'espressomd/espresso' }}
1414
environment: deploy_documentation
1515
steps:
16-
- name: Install pandoc
17-
uses: r-lib/actions/setup-pandoc@v2
16+
- name: Install dependencies
17+
run: sudo apt-get install --no-install-recommends -y curl rsync ssh unzip make grep sed jq python3 pandoc
1818
- name: Setup SSH agent
1919
uses: webfactory/ssh-agent@v0.9.0
2020
with:
2121
ssh-private-key: ${{ secrets.GH_PAGES_SSH_PRIVATE_KEY }}
2222
- name: Checkout
2323
uses: actions/checkout@main
2424
- name: Deploy documentation
25-
uses: ./.github/actions/deploy_docs
25+
shell: sh
26+
env:
27+
GITLAB_READ_API: ${{ secrets.GITLAB_READ_API }}
28+
run: maintainer/CI/make_gh_pages.sh

maintainer/CI/make_gh_pages.sh

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
#!/usr/bin/env sh
2+
#
3+
# Copyright (C) 2021-2024 The ESPResSo project
4+
#
5+
# This file is part of ESPResSo.
6+
#
7+
# ESPResSo is free software: you can redistribute it and/or modify
8+
# it under the terms of the GNU General Public License as published by
9+
# the Free Software Foundation, either version 3 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# ESPResSo is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
#
20+
21+
set -e # exit on first non-zero return code
22+
set -x # print each command line before executing it
23+
24+
if [ ! "${GITHUB_ACTIONS}" = "true" ]; then
25+
echo "This script is meant to be executed by a GitHub Actions workflow";
26+
exit 1;
27+
fi
28+
29+
# checkout GitHub pages
30+
cd "${HOME}"
31+
git clone --quiet git@github.com:espressomd/espressomd.github.io.git
32+
cd espressomd.github.io
33+
34+
# check if already up-to-date (i.e. the commit SHA of the
35+
# generated docs is identical to the current commit SHA)
36+
LAST_COMMIT=$(git log -1 --pretty='format:"%s"' remotes/origin/main)
37+
NEXT_COMMIT="Documentation for ${GITHUB_SHA}"
38+
if [ "${NEXT_COMMIT}" = "${LAST_COMMIT}" ]; then
39+
echo "Documentation already up-to-date.";
40+
exit 0;
41+
fi
42+
43+
# download artifacts
44+
gitlab_rest_api_get() {
45+
# shellcheck disable=SC2068
46+
curl --fail --location --request GET --header "PRIVATE-TOKEN: ${GITLAB_READ_API}" $@
47+
}
48+
rest_api="https://gitlab.icp.uni-stuttgart.de/api/v4"
49+
project_id=390
50+
# get the status of the most recent CI pipelines
51+
gitlab_rest_api_get --silent "${rest_api}/projects/${project_id}/pipelines?per_page=60" > pipelines.json
52+
# get the most recent successful nightly build (where tutorials are available)
53+
# and the most recent successful build (where sphinx and doxygen are available)
54+
pipeline_sched_id=$(jq '[ .[] | select(.ref=="python" and .status=="success" and .source=="schedule") ][0].id' pipelines.json)
55+
pipeline_merge_id=$(jq '[ .[] | select(.ref=="python" and .status=="success") ][0].id' pipelines.json)
56+
gitlab_rest_api_get --silent "${rest_api}/projects/${project_id}/pipelines/${pipeline_sched_id}/jobs?per_page=100" > jobs_scheduled_pipeline.json
57+
gitlab_rest_api_get --silent "${rest_api}/projects/${project_id}/pipelines/${pipeline_merge_id}/jobs?per_page=100" > jobs_branch_head_pipeline.json
58+
# get the tutorial, sphinx, and doxygen CI job ids and download their artifacts
59+
tutorial_job_id=$(jq '.[] | select(.name=="run_tutorials").id' jobs_scheduled_pipeline.json)
60+
doxygen_job_id=$(jq '.[] | select(.name=="run_doxygen").id' jobs_branch_head_pipeline.json)
61+
sphinx_job_id=$(jq '.[] | select(.name=="check_sphinx").id' jobs_branch_head_pipeline.json)
62+
gitlab_rest_api_get --output tutorials.zip "${rest_api}/projects/${project_id}/jobs/${tutorial_job_id}/artifacts"
63+
gitlab_rest_api_get --output doxygen.zip "${rest_api}/projects/${project_id}/jobs/${doxygen_job_id}/artifacts"
64+
gitlab_rest_api_get --output sphinx.zip "${rest_api}/projects/${project_id}/jobs/${sphinx_job_id}/artifacts"
65+
if grep -F '<!DOCTYPE html>' ./*.zip; then
66+
echo "The artifacts could not be downloaded.";
67+
exit 1;
68+
fi
69+
unzip -q "*.zip"
70+
71+
# create a fresh main branch containing the docs of old releases
72+
git config --global user.email "noreply@icp.uni-stuttgart.de"
73+
git config --global user.name "espresso-ci"
74+
git checkout -b new_main remotes/origin/releases
75+
76+
# generate the landing page by merging the branch containing the
77+
# HTML theme and Markdown files, then convert them to HTML files
78+
git merge --quiet --commit --no-edit --allow-unrelated-histories remotes/origin/landing_page
79+
make tutorials.md
80+
make videos.md
81+
for filename in *.md; do
82+
make "${filename%.md}.html";
83+
done
84+
rm ./*_header.html
85+
git add ./*.html
86+
git clean -f
87+
git rm ./*.md ./*.py Makefile
88+
git commit --quiet -m "Generate landing page"
89+
90+
# add devel documentation
91+
rsync -a --delete --exclude="*.md5" --exclude="*.map" "build/doc/doxygen/html/" dox/
92+
rsync -a --delete --exclude=".buildinfo" "build/doc/sphinx/html/" doc/
93+
rsync -a --delete "build/doc/tutorials/html/" tutorials/
94+
git add doc dox tutorials
95+
git commit --quiet -m "${NEXT_COMMIT}"
96+
97+
# deploy
98+
git push -f origin new_main:main

0 commit comments

Comments
 (0)