diff --git a/generateChangemarks/.gitlab-ci.yml b/generateChangemarks/.gitlab-ci.yml index b5cd5568f00a62e1087454f138a7b9d0aa6f3889..d632f64314b7a4c81f2657be879491058dfedc35 100644 --- a/generateChangemarks/.gitlab-ci.yml +++ b/generateChangemarks/.gitlab-ci.yml @@ -91,10 +91,10 @@ pages: TAG_NAME: "upgrade" before_script: - | - curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/publish_on_pages%2Esh/raw?ref=master" >> publish_on_pages.sh + curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/publish_on_pages%2Esh/raw?ref=addDiffCR" >> publish_on_pages.sh - chmod +x publish_on_pages.sh - | - curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/updateIndex%2Epy/raw?ref=master" >> updateIndex.py + curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/updateIndex%2Epy/raw?ref=addDiffCR" >> updateIndex.py - | curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/index%2Ehtml/raw?ref=master" >> index.html - | diff --git a/publish_on_pages.sh b/publish_on_pages.sh index 751a21b679f7fee4e9d12bc1ca920faff7c2a091..11755a5f7d74849f783a44433bb83fc9124e3245 100644 --- a/publish_on_pages.sh +++ b/publish_on_pages.sh @@ -23,26 +23,41 @@ fi set -e echo "------ Get the previous GitLab Pages content --------" +# Move all folders except the "baselines" folder if baselines folder exists +if [ -d "public/baselines" ]; then + echo "Baselines already moved to baselines/"; +else + mkdir -p "public/baselines" + for folder in public/*; do + if [ -d "$folder" ] && [ "$(basename "$folder")" != "baselines" ]; then + mv "$folder" "public/baselines/" + echo "Moved $(basename "$folder") to public/baselines" + fi + done + # Move index.html with new location + mv "public/index.html" "public/baselines/" + +fi echo "------ Add/update content --------" if [ $4 == 'upgrade' ]; then echo 'Upgrading index.html...' docker run --rm -v $(pwd):/tmp -w /tmp "$DOCKER_IMAGE" python3 $1 -u "$7_$4" "$4/$7_$4.docx" "$5" elif [ $6 == 'true' ]; then - echo 'Removing all web pages content...' - rm -r public/*; - mkdir -p "public/$4" + echo 'Removing all baselines ...' + rm -r public/baselines/*; + mkdir -p "public/baselines/$4" ls public/ - cp -r -f "$7_$4.docx" public/$4 + cp -r -f "$7_$4.docx" public/baselines/$4 docker run --rm -v $(pwd):/tmp -w /tmp "$DOCKER_IMAGE" python3 $1 "$7_$4" "$4/$7_$4.docx" "$5" elif [ $6 == 'false' ]; then - mkdir -p "public/$4" + mkdir -p "public/baselines/$4" ls public/ - cp -r -f "$7_$4.docx" public/$4 + cp -r -f "$7_$4.docx" public/baselines/$4 docker run --rm -v $(pwd):/tmp -w /tmp "$DOCKER_IMAGE" python3 $1 "$7_$4" "$4/$7_$4.docx" "$5" else echo 'Removing entry for ' $6 - rm -r -f public/$6 + rm -r -f public/baselines/$6 docker run --rm -v $(pwd):/tmp -w /tmp "$DOCKER_IMAGE" python3 $1 -re "$7_$4" "$4/$7_$4.docx" "$5" fi diff --git a/updateIndex.py b/updateIndex.py index 74c513ad94390e6caa52b2238a490fc5a6f5c180..a03521c6eca2e1b3dbc06d35aa9787f6a85befa9 100644 --- a/updateIndex.py +++ b/updateIndex.py @@ -12,12 +12,12 @@ import argparse, os def upgradeIndex(args: argparse.Namespace) -> None: # Check if index.htm exists - if not os.path.exists('public/index.html'): + if not os.path.exists('public/baselines/index.html'): print("'index.html' does not exist yet, Upgrade is not needed") exit() else: # Read the source HTML file - with open('public/index.html', 'r', encoding='utf-8') as source_file: + with open('public/baselines/index.html', 'r', encoding='utf-8') as source_file: source_html = source_file.read() # Read the destination HTML file @@ -46,26 +46,22 @@ def upgradeIndex(args: argparse.Namespace) -> None: exit(1) # Save the updated destination HTML - with open('public/index.html', 'w', encoding='utf-8') as dest_updated_file: + with open('public/baselines/index.html', 'w', encoding='utf-8') as dest_updated_file: dest_updated_file.write(str(dest_soup)) - - # Read index HTML - with open('public/index.html', 'r', encoding='utf-8') as file: - html_content = file.read() print("Index.html upgraded") def updateIndex(args:argparse.Namespace) -> None: # Check if index.htm exists - if not os.path.exists('public/index.html'): + if not os.path.exists('public/baselines/index.html'): print("'index.html' does not exist yet, using template") with open(args.indexTemplate, 'r', encoding='utf-8') as file: html_content = file.read() else: # Read index HTML - with open('public/index.html', 'r', encoding='utf-8') as file: + with open('public/baselines/index.html', 'r', encoding='utf-8') as file: html_content = file.read() # Analyze index content with BeautifulSoup @@ -97,7 +93,7 @@ def updateIndex(args:argparse.Namespace) -> None: document_list.append(li) # Save the updated index.html file - with open('public/index.html', 'w', encoding='utf-8') as file: + with open('public/baselines/index.html', 'w', encoding='utf-8') as file: file.write(str(soup)) print("Index.html updated")