Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade CD pipeline #5022

Open
wants to merge 1 commit into
base: python
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 0 additions & 53 deletions .github/actions/deploy_docs/action.yml

This file was deleted.

15 changes: 9 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,27 @@ name: deploy

on:
schedule:
- cron: '0 7 * * *'
- cron: '0 7 * * *' # daily at 07:00 AM

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

jobs:
deploy_docs:
runs-on: ubuntu-22.04
if: github.repository == 'espressomd/espresso'
runs-on: ubuntu-24.04
if: ${{ github.repository == 'espressomd/espresso' }}
environment: deploy_documentation
steps:
- name: Install pandoc
uses: r-lib/actions/setup-pandoc@v2
- name: Install dependencies
run: sudo apt-get install --no-install-recommends -y curl rsync ssh unzip make grep sed jq python3 pandoc
- name: Setup SSH agent
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.GH_PAGES_SSH_PRIVATE_KEY }}
- name: Checkout
uses: actions/checkout@main
- name: Deploy documentation
uses: ./.github/actions/deploy_docs
shell: sh
env:
GITLAB_READ_API: ${{ secrets.GITLAB_READ_API }}
run: maintainer/CI/make_gh_pages.sh
94 changes: 94 additions & 0 deletions maintainer/CI/make_gh_pages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/usr/bin/env sh
#
# Copyright (C) 2021-2024 The ESPResSo project
#
# This file is part of ESPResSo.
#
# ESPResSo is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ESPResSo is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

set -e # exit on first non-zero return code
set -x # print each command line before executing it

if [ ! "${GITHUB_ACTIONS}" = "true" ]; then
echo "This script is meant to be executed by a GitHub Actions workflow";
exit 1;
fi

# checkout GitHub pages
cd "${HOME}"
git clone --quiet [email protected]:espressomd/espressomd.github.io.git
cd espressomd.github.io

# check if already up-to-date (i.e. the commit SHA of the
# generated docs is identical to the current commit SHA)
LAST_COMMIT=$(git log -1 --pretty='format:"%s"' remotes/origin/main)
NEXT_COMMIT="Documentation for ${GITHUB_SHA}"
if [ "${NEXT_COMMIT}" = "${LAST_COMMIT}" ]; then
echo "Documentation already up-to-date.";
exit 0;
fi

# download artifacts
gitlab_rest_api_get() {
# shellcheck disable=SC2068
curl --fail --location --request GET --header "PRIVATE-TOKEN: ${GITLAB_READ_API}" $@
}
rest_api="https://gitlab.icp.uni-stuttgart.de/api/v4"
project_id=390
gitlab_rest_api_get --silent "${rest_api}/projects/${project_id}/pipelines?per_page=60" > pipelines.json
pipeline_sched_id=$(jq '[ .[] | select(.ref=="python" and .status=="success" and .source=="schedule") ][0].id' pipelines.json)
pipeline_merge_id=$(jq '[ .[] | select(.ref=="python" and .status=="success") ][0].id' pipelines.json)
gitlab_rest_api_get --silent "${rest_api}/projects/${project_id}/pipelines/${pipeline_sched_id}/jobs?per_page=100" > jobs_scheduled_pipeline.json
gitlab_rest_api_get --silent "${rest_api}/projects/${project_id}/pipelines/${pipeline_merge_id}/jobs?per_page=100" > jobs_branch_head_pipeline.json
tutorial_job_id=$(jq '.[] | select(.name=="run_tutorials").id' jobs_scheduled_pipeline.json)
doxygen_job_id=$(jq '.[] | select(.name=="run_doxygen").id' jobs_branch_head_pipeline.json)
sphinx_job_id=$(jq '.[] | select(.name=="check_sphinx").id' jobs_branch_head_pipeline.json)
gitlab_rest_api_get --output tutorials.zip "${rest_api}/projects/${project_id}/jobs/${tutorial_job_id}/artifacts"
gitlab_rest_api_get --output doxygen.zip "${rest_api}/projects/${project_id}/jobs/${doxygen_job_id}/artifacts"
gitlab_rest_api_get --output sphinx.zip "${rest_api}/projects/${project_id}/jobs/${sphinx_job_id}/artifacts"
if grep -F '<!DOCTYPE html>' ./*.zip; then
echo "The artifacts could not be downloaded.";
exit 1;
fi
unzip -q "*.zip"

# create a fresh main branch containing the docs of old releases
git config --global user.email "[email protected]"
git config --global user.name "espresso-ci"
git checkout -b new_main remotes/origin/releases

# generate the landing page by merging the branch containing the
# HTML theme and Markdown files, then convert them to HTML files
git merge --quiet --commit --no-edit --allow-unrelated-histories remotes/origin/landing_page
make tutorials.md
make videos.md
for filename in *.md; do
make "${filename%.md}.html";
done
rm ./*_header.html
git add ./*.html
git clean -f
git rm ./*.md ./*.py Makefile
git commit --quiet -m "Generate landing page"

# add devel documentation
rsync -a --delete --exclude="*.md5" --exclude="*.map" "build/doc/doxygen/html/" dox/
rsync -a --delete --exclude=".buildinfo" "build/doc/sphinx/html/" doc/
rsync -a --delete "build/doc/tutorials/html/" tutorials/
git add doc dox tutorials
git commit --quiet -m "${NEXT_COMMIT}"

# deploy
git push -f origin new_main:main
Loading