diff --git a/.github/actions/deploy_docs/action.yml b/.github/actions/deploy_docs/action.yml deleted file mode 100644 index 4351c6c3f92..00000000000 --- a/.github/actions/deploy_docs/action.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: 'Deploy documentation' -description: 'Deploy ESPResSo documentation' -runs: - using: "composite" - steps: - - run: | - # checkout github pages - cd "${HOME}" - git clone --quiet git@github.com: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 - curl https://gitlab.icp.uni-stuttgart.de/espressomd/espresso/-/jobs/artifacts/python/download?job=run_tutorials --fail -L -o tutorials.zip - curl https://gitlab.icp.uni-stuttgart.de/espressomd/espresso/-/jobs/artifacts/python/download?job=run_doxygen --fail -L -o doxygen.zip - curl https://gitlab.icp.uni-stuttgart.de/espressomd/espresso/-/jobs/artifacts/python/download?job=check_sphinx --fail -L -o sphinx.zip - if grep -F '' *.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 "noreply@icp.uni-stuttgart.de" - 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 - shell: bash diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7ab35c52b74..c99b3b7e8fc 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -2,19 +2,19 @@ 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/ssh-agent@v0.9.0 with: @@ -22,4 +22,7 @@ jobs: - 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 diff --git a/maintainer/CI/make_gh_pages.sh b/maintainer/CI/make_gh_pages.sh new file mode 100755 index 00000000000..d8cb9c7b26f --- /dev/null +++ b/maintainer/CI/make_gh_pages.sh @@ -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 . +# + +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 git@github.com: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 '' ./*.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 "noreply@icp.uni-stuttgart.de" +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