From ea7b39dee04f6646f57c10a85f11cd5f20e366f8 Mon Sep 17 00:00:00 2001 From: anton Date: Fri, 7 Jun 2024 17:58:48 +0200 Subject: [PATCH 1/2] FAIRSPC-87: added workflow to Build and deploy docs to Github Pages and fixed table in doc --- .github/workflows/build_and_deploy_docs.yaml | 39 ++++++++++++++++++++ README.adoc | 3 +- docs/deploy.sh | 18 +++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build_and_deploy_docs.yaml create mode 100755 docs/deploy.sh diff --git a/.github/workflows/build_and_deploy_docs.yaml b/.github/workflows/build_and_deploy_docs.yaml new file mode 100644 index 000000000..8af7555c7 --- /dev/null +++ b/.github/workflows/build_and_deploy_docs.yaml @@ -0,0 +1,39 @@ +# This workflow is triggered on any PR's changes + +name: Build and deploy docs to Github Pages + +on: + push: + branches: + - bugfix/FAIRSPC-87 + + +jobs: + build-saturn: + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Log details + run: | + BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} + echo "Triggered on branch: $BRANCH" + + - name: Set up Ruby (required for gem installation) + uses: ruby/setup-ruby@v1 + with: + ruby-version: '2.7' + + - name: Install Asciidoctor + run: | + gem install asciidoctor + gem install asciidoctor-pdf + gem install rouge + + - name: Run Build Docs script + run: ./docs/build.sh + + - name: Run Deploy Docs script + run: ./docs/deploy.sh + diff --git a/README.adoc b/README.adoc index 6595a1e1a..1ccbdccba 100644 --- a/README.adoc +++ b/README.adoc @@ -1900,7 +1900,8 @@ Multiple external Fairspace metadata pages can be configured simultaneously. A l | String to be used as a display name of the metadata source. | ``url`` | Fairspace instance to connect to. If the url is not specified, the metadata source will be treated as the internal one. -| *Important!* There should only be a single configuration of internal metadata (only the first one will not be ignored). + +*Important!* There should only be a single configuration of internal metadata (only the first one will not be ignored). | ``icon-name`` | Name of an icon configured in the "icons" section of values.yaml file. If the name is not specified, there will be a default icon used. |=== diff --git a/docs/deploy.sh b/docs/deploy.sh new file mode 100755 index 000000000..afbc8f169 --- /dev/null +++ b/docs/deploy.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +cd .. +git clone "https://${CI_SERVICE_ACCOUNT_USER}:${CI_SERVICE_ACCOUNT_PASSWORD}@github.com/${DOCUMENTATION_REPO}" fairspace-docs +export DOCS_DIR=$(pwd)/fairspace-docs + +cp -r ./fairspace/docs/build/* "${DOCS_DIR}/" + +pushd "${DOCS_DIR}" +if [ ! "$(git status -s)" == "" ]; then + echo "Committing changes to ${DOCUMENTATION_REPO} ..." + git add . + git commit -a -m "Update from the documentation branch of ${TRAVIS_REPO_SLUG}." + git push "https://${GITHUB_USERNAME}:${GITHUB_PASSWORD}@github.com/${DOCUMENTATION_REPO}" main +else + echo "Documentation unchanged." +fi +popd From 326fe1ff423532b7f777757175c56695799ad93d Mon Sep 17 00:00:00 2001 From: anton Date: Sat, 8 Jun 2024 00:02:57 +0200 Subject: [PATCH 2/2] FAIRSPC-87: added workflow to Build and deploy docs to Github Pages and fixed table in doc --- .github/workflows/build_and_deploy_docs.yaml | 85 +++++++++++++++++--- docs/build.sh | 34 -------- docs/deploy.sh | 18 ----- 3 files changed, 75 insertions(+), 62 deletions(-) delete mode 100755 docs/build.sh delete mode 100755 docs/deploy.sh diff --git a/.github/workflows/build_and_deploy_docs.yaml b/.github/workflows/build_and_deploy_docs.yaml index 8af7555c7..4c83ce6ad 100644 --- a/.github/workflows/build_and_deploy_docs.yaml +++ b/.github/workflows/build_and_deploy_docs.yaml @@ -1,12 +1,9 @@ -# This workflow is triggered on any PR's changes - name: Build and deploy docs to Github Pages on: push: branches: - - bugfix/FAIRSPC-87 - + - release jobs: build-saturn: @@ -23,17 +20,85 @@ jobs: - name: Set up Ruby (required for gem installation) uses: ruby/setup-ruby@v1 with: - ruby-version: '2.7' + ruby-version: '3.3.2' - - name: Install Asciidoctor + - name: Install Asciidoctor to build docs run: | gem install asciidoctor gem install asciidoctor-pdf gem install rouge - - name: Run Build Docs script - run: ./docs/build.sh + - name: Build Docs - Collect needed files + run: | + set -e + + # Initialize variables + PROJECT_FILES=( + "projects/saturn/src/main/resources/log4j2.properties" + "projects/saturn/src/main/resources/system-vocabulary.ttl" + "projects/saturn/taxonomies.ttl" + "projects/saturn/views.yaml" + "projects/saturn/vocabulary.ttl" + ) + BUILD_DIR=./docs/build + version=$(cat VERSION) + + # Create build directory + mkdir -p $BUILD_DIR/docs + + # Copy all files to the build directory + cp ./README.adoc $BUILD_DIR + sed -i -e "s/VERSION/${version}/" $BUILD_DIR/README.adoc + cp -r ./docs/images $BUILD_DIR/docs/ + for f in ${PROJECT_FILES[*]}; do + mkdir -p "$BUILD_DIR/$(dirname "$f")" + cp "$f" "$BUILD_DIR/"$(dirname "$f")"" + done - - name: Run Deploy Docs script - run: ./docs/deploy.sh + - name: Build Docs - Generate PDF and HTML + run: | + set -e + + BUILD_DIR=./docs/build + + asciidoctor-pdf -a pdf-theme=./docs/pdf-theme.yml -o $BUILD_DIR/Fairspace.pdf $BUILD_DIR/README.adoc || { + echo "Error building PDF" + popd + exit 1 + } + + asciidoctor -a toc=left -D $BUILD_DIR/ -o index.html $BUILD_DIR/README.adoc || { + echo "Error building site" + popd + exit 1 + } + + rm $BUILD_DIR/README.adoc + - name: Deploy Docs (push to Github Pages, will be deployed automatically) + env: + CI_SERVICE_ACCOUNT_USER: ${{ secrets.CI_SERVICE_ACCOUNT_USER }} + CI_SERVICE_ACCOUNT_PASSWORD: ${{ secrets.FNS_PAT }} + DOCS_REPOSITORY_NAME: ${{ vars.DOCS_REPOSITORY_NAME }} + run: | + set -e + + DOCS_REPO_URL="https://${CI_SERVICE_ACCOUNT_USER}:${CI_SERVICE_ACCOUNT_PASSWORD}@github.com/thehyve/${DOCS_REPOSITORY_NAME}" + echo "Cloning documentation repository ${DOCS_REPOSITORY_NAME} ..." + git clone --branch main "${DOCS_REPO_URL}" fairspace-docs + + DOCS_DIR=$(pwd)/fairspace-docs + echo "Copying documentation to ${DOCS_DIR} ..." + cp -r ./docs/build/* "${DOCS_DIR}/" + cd "${DOCS_DIR}" + + if [ ! "$(git status -s)" == "" ]; then + echo "Committing and pushing changes to ${DOCS_REPOSITORY_NAME} ..." + git config --global user.email "${CI_SERVICE_ACCOUNT_USER}@thehyve.nl" + git config --global user.name "${CI_SERVICE_ACCOUNT_USER}" + git add . + git commit -a -m "Update documentation" + git push "${DOCS_REPO_URL}" main + else + echo "Documentation unchanged." + fi diff --git a/docs/build.sh b/docs/build.sh deleted file mode 100755 index b8356ac20..000000000 --- a/docs/build.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash - -PROJECT_FILES=( - "projects/saturn/src/main/resources/log4j2.properties" - "projects/saturn/src/main/resources/system-vocabulary.ttl" - "projects/saturn/taxonomies.ttl" - "projects/saturn/views.yaml" - "projects/saturn/vocabulary.ttl" -) - - -here=$(dirname "${0}") -pushd "${here}" -version=$(cat ../VERSION) -mkdir -p build/docs -cp ../README.adoc build/ -sed -i -e "s/VERSION/${version}/" build/README.adoc -cp -r images build/docs/ -for f in ${PROJECT_FILES[*]}; do - mkdir -p "build/$(dirname "$f")" - cp "../$f" "build/"$(dirname "$f")"" -done -asciidoctor-pdf -a pdf-theme=pdf-theme.yml -o build/Fairspace.pdf build/README.adoc || { - echo "Error building PDF" - popd - exit 1 -} -asciidoctor -a toc=left -D build/ -o index.html build/README.adoc || { - echo "Error building site" - popd - exit 1 -} -rm build/README.adoc -popd diff --git a/docs/deploy.sh b/docs/deploy.sh deleted file mode 100755 index afbc8f169..000000000 --- a/docs/deploy.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash - -cd .. -git clone "https://${CI_SERVICE_ACCOUNT_USER}:${CI_SERVICE_ACCOUNT_PASSWORD}@github.com/${DOCUMENTATION_REPO}" fairspace-docs -export DOCS_DIR=$(pwd)/fairspace-docs - -cp -r ./fairspace/docs/build/* "${DOCS_DIR}/" - -pushd "${DOCS_DIR}" -if [ ! "$(git status -s)" == "" ]; then - echo "Committing changes to ${DOCUMENTATION_REPO} ..." - git add . - git commit -a -m "Update from the documentation branch of ${TRAVIS_REPO_SLUG}." - git push "https://${GITHUB_USERNAME}:${GITHUB_PASSWORD}@github.com/${DOCUMENTATION_REPO}" main -else - echo "Documentation unchanged." -fi -popd