Skip to content
Merged

Test #26

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
45c0501
chore: add PR automation workflows and scripts from develop
mckeea Dec 1, 2025
ee79eab
Update LLM cache [skip ci]
actions-user Dec 1, 2025
34c4b1b
chore: add PR automation workflows and scripts from develop
mckeea Dec 1, 2025
b79f05e
Merge branch 'test' of https://github.com/eea/CLMS_documents into test
mckeea Dec 1, 2025
cf73c2e
feat(docs): update CLCplus Backbone, Coastal Zones, Copernicus Land D…
mckeea Dec 2, 2025
55839fd
Update LLM cache [skip ci]
actions-user Dec 2, 2025
1c33f0b
Hotfix
mckeea Dec 2, 2025
ee65a2c
Update LLM cache [skip ci]
actions-user Dec 2, 2025
36d04cf
fix: prevent duplicate changelog entries, sync versions, and enable m…
mckeea Dec 2, 2025
ad7159f
Update LLM cache [skip ci]
actions-user Dec 2, 2025
37d815a
fix: gitattributes update
mckeea Dec 2, 2025
d4f786c
fix: avoid duplicates in versions and changelogs
mckeea Dec 2, 2025
6e91690
[skip ci] fix: versions.json
mckeea Dec 2, 2025
a593579
fix: change_logs.json
mckeea Dec 2, 2025
c70d024
Update LLM cache [skip ci]
actions-user Dec 2, 2025
fad3c2c
fix: synchronize versions.json and change_logs.json [skip ci]
mckeea Dec 3, 2025
97c887f
Update LLM cache [skip ci]
actions-user Dec 3, 2025
7af4c9c
fix: normalize file paths in version/changelog updates [skip ci]
mckeea Dec 3, 2025
cf120e8
fix: versions.json and change_logs.json [skip ci]
mckeea Dec 3, 2025
9096a9b
Update LLM cache [skip ci]
actions-user Dec 3, 2025
b1e006c
fix: correct path normalization for vesion/changelog update [skip ci]
mckeea Dec 3, 2025
e555037
Update LLM cache [skip ci]
actions-user Dec 3, 2025
c5a4e09
fix: avoid duplicates in versions and changelogs
mckeea Dec 3, 2025
a82515d
Merge branch 'test' of https://github.com/eea/CLMS_documents into test
mckeea Dec 3, 2025
48c24f5
fix: versions.json and change_logs.json [skip ci]
mckeea Dec 3, 2025
6d6e7e9
fix: inject changelog correctly [skip ci]
mckeea Dec 3, 2025
a74f98f
release(docs): various updates
mckeea Dec 4, 2025
32d01cf
Update LLM cache [skip ci]
actions-user Dec 4, 2025
551b28a
Merge branch 'main' into test
mckeea Dec 4, 2025
2beffa7
Develop (#25)
mckeea Feb 9, 2026
be87cab
Merge branch 'main' into test
mckeea Feb 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
31 changes: 26 additions & 5 deletions .github/scripts/build-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fi

# Render all files together (changelog filter uses original-filename from YAML headers)
echo "🔄 Rendering all documents to HTML..."
QUARTO_CHROMIUM_HEADLESS_MODE=new quarto render --to html --no-clean
QUARTO_CHROMIUM_HEADLESS_MODE=new quarto render --to html --no-clean

# Backup the correct sitemap as it may be overwritten by next operations
sleep 5
Expand All @@ -57,17 +57,38 @@ node ../.github/scripts/generate_index_all.mjs
echo "📄 Render only index.qmd files using 'index' profile"
mv _quarto.yml _quarto_not_used.yml
mv _quarto-index.yml _quarto.yml
index_count=$(find ./ -type f -name index.qmd | wc -l)
echo " Rendering $index_count index files..."
find ./ -type f -name index.qmd -print0 | while IFS= read -r -d '' src; do
echo "🔧 Rendering $src using profile=index..."
QUARTO_CHROMIUM_HEADLESS_MODE=new quarto render "$src" --profile index --to html --no-clean $QUARTO_FLAGS
QUARTO_CHROMIUM_HEADLESS_MODE=new quarto render "$src" --profile index --to html --no-clean --quiet $QUARTO_FLAGS
done
mv _quarto.yml _quarto-index.yml
cp _quarto_not_used.yml _quarto.yml && rm _quarto_not_used.yml


echo "📄 Converting .docx files to .pdf..."
timeout 3s ../.github/scripts/convert_docx_to_pdf.sh || true
timeout 10m ../.github/scripts/convert_docx_to_pdf.sh
docx_count=$(find _site -name "*.docx" -type f | wc -l)
echo " Found $docx_count DOCX files to convert"

# Quick 3-second test run
echo " Running quick test conversion..."
timeout 3s ../.github/scripts/convert_docx_to_pdf.sh 2>&1 | head -20 || true

# Full conversion with detailed error reporting
echo " Starting full PDF conversion (timeout: 20m)..."
if ! timeout 20m ../.github/scripts/convert_docx_to_pdf.sh 2>&1 | tee conversion.log; then
exit_code=$?
echo "❌ PDF conversion failed with exit code: $exit_code"
echo " Last 30 lines of output:"
tail -30 conversion.log
echo " DOCX files present:"
find _site -name "*.docx" -type f | head -10
exit $exit_code
fi

echo "✅ PDF conversion completed successfully"
pdf_count=$(find _site -name "*.pdf" -type f | wc -l)
echo " Generated $pdf_count PDF files"

# Clean up DOCX files if requested (they're only needed for PDF conversion)
if [[ -n "$SKIP_DOCX" ]]; then
Expand Down
17 changes: 8 additions & 9 deletions .github/scripts/external_publish_main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ get_changed_files() {
git ls-tree -r --name-only "$PUBLISH_COMMIT" > changed-files.txt
# Remove specific files we want to ignore
sed -i '/^\.gitignore$/d; /^\.github\/workflows\/trigger\.yml$/d' changed-files.txt
cat changed-files.txt
file_count=$(wc -l < changed-files.txt)
echo "Found $file_count changed file(s)"
}

check_files_within_project() {
Expand Down Expand Up @@ -73,10 +74,7 @@ check_for_changes() {
return 1
fi

echo "✅ Modified files:"
printf '%s\n' "${MODIFIED_FILES[@]}"
echo "🗑️ Deleted files:"
printf '%s\n' "${DELETED_FILES[@]}"
echo "✅ Changes detected: ${#MODIFIED_FILES[@]} modified, ${#DELETED_FILES[@]} deleted"

return 0
}
Expand All @@ -95,10 +93,11 @@ apply_file_changes() {
run_git "removing deleted files" rm "${DELETED_FILES[@]}"
fi

# Stage modified files
for file in "${MODIFIED_FILES[@]}"; do
run_git "adding $file to staging" add "$file"
done
# Stage all modified files at once
if [ "${#MODIFIED_FILES[@]}" -gt 0 ]; then
git add "${MODIFIED_FILES[@]}" 2>&1 | head -1 || true
echo "Staged ${#MODIFIED_FILES[@]} modified file(s)"
fi
}

generate_commit_message() {
Expand Down
71 changes: 30 additions & 41 deletions .github/scripts/group_docs_by_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ def group_qmd_files_by_category(source_dir="origin_DOCS", target_dir="DOCS"):
secret_mappings = load_secret_map()
updated = False

# Counters for summary
categorized_count = 0
non_browsable_count = 0
new_non_browsable_assignments = 0

# Find all .qmd files
qmd_files = [
f
Expand Down Expand Up @@ -179,15 +184,13 @@ def group_qmd_files_by_category(source_dir="origin_DOCS", target_dir="DOCS"):
secret_mappings, rel_source, base, url
)
updated = True
new_non_browsable_assignments += 1
print(
f"\t[non-browsable] Assigned new random base '{base}' for {rel_source}"
)
else:
base = mapping["base"]
url = mapping["url"]
print(
f"\t[non-browsable] Using existing base '{base}' for {rel_source}"
)

target_file = nb_dir / f"{base}.qmd"
shutil.copy2(qmd_file, target_file)
Expand All @@ -202,9 +205,6 @@ def group_qmd_files_by_category(source_dir="origin_DOCS", target_dir="DOCS"):
if target_media_dir.exists():
shutil.rmtree(target_media_dir)
shutil.copytree(orig_media_dir, target_media_dir)
print(
f"\t\tCopied media directory: {base}-media (renamed for non-browsable)"
)
# Update references in the copied .qmd file
try:
with open(target_file, "r", encoding="utf-8") as f:
Expand All @@ -215,16 +215,11 @@ def group_qmd_files_by_category(source_dir="origin_DOCS", target_dir="DOCS"):
content = content.replace(old_media, new_media)
with open(target_file, "w", encoding="utf-8") as f:
f.write(content)
print(
f"\t\tRewrote media references in {base}.qmd (non-browsable)"
)
except Exception as e:
print(
f"\t\t[ERROR] Failed to rewrite media references in {base}.qmd: {e}"
)
print(
f"\t[non-browsable] Copied {qmd_file.name} → non-browsable/{base}.qmd (non-browsable)"
)
non_browsable_count += 1
else:
# Normal doc: group by category, prefix with project name to avoid collisions
target_directory = get_directory_for_category(category)
Expand All @@ -245,7 +240,6 @@ def group_qmd_files_by_category(source_dir="origin_DOCS", target_dir="DOCS"):
if target_media_dir.exists():
shutil.rmtree(target_media_dir)
shutil.copytree(orig_media_dir, target_media_dir)
print(f"\t\tCopied media directory: {prefix}{qmd_file.stem}-media")
# Rewrite media references in the copied QMD file
if prefix:
try:
Expand All @@ -258,41 +252,30 @@ def group_qmd_files_by_category(source_dir="origin_DOCS", target_dir="DOCS"):
content = content.replace(old_media, new_media)
with open(target_file, "w", encoding="utf-8") as f:
f.write(content)
print(
f"\t\tRewrote media references in {prefix}{qmd_file.name}"
)
except Exception as e:
print(
f"\t\t[ERROR] Failed to rewrite media references in {prefix}{qmd_file.name}: {e}"
)
if category:
if category in CATEGORY_TO_DIRECTORY_MAP:
print(
f"\tCopied {qmd_file.name} → {target_directory}/ as {prefix}{qmd_file.name} (category: {category})"
)
else:
print(
f"\tCopied {qmd_file.name} → {target_directory}/ as {prefix}{qmd_file.name}"
)
else:
print(
f"\tCopied {qmd_file.name} → {target_directory}/ as {prefix}{qmd_file.name} (no category found)"
)
categorized_count += 1

# Save updated secret mapping if changed
if updated:
save_secret_map(secret_mappings)
print(f"[non-browsable] Updated mapping file: {NON_BROWSABLE_MAP_PATH}")
else:
print(f"[non-browsable] No changes to mapping file: {NON_BROWSABLE_MAP_PATH}")
if new_non_browsable_assignments > 0:
print(
f"[non-browsable] Created {new_non_browsable_assignments} new URL mappings"
)

# Save path mappings for changelog system
mapping_file = target_path / "_meta" / ".temp_path_mapping.json"
import json

with open(mapping_file, "w", encoding="utf-8") as f:
json.dump(path_mappings, f, indent=2)
print(f"[path-mapping] Saved {len(path_mappings)} path mappings to {mapping_file}")

print(
f"Processed {len(qmd_files)} files: {categorized_count} categorized, {non_browsable_count} non-browsable."
)


def copy_excluded_dirs(source_dir="origin_DOCS", target_dir="DOCS"):
Expand All @@ -317,6 +300,7 @@ def inject_original_filename_in_qmd_files(docs_dir="origin_DOCS"):
print("Injecting original filename field into QMD files...")

processed_files = 0
skipped_files = 0

# Find all .qmd files in the docs directory
for qmd_file in docs_path.rglob("*.qmd"):
Expand All @@ -337,13 +321,15 @@ def inject_original_filename_in_qmd_files(docs_dir="origin_DOCS"):
print(
f" Warning: {qmd_file.name} doesn't have YAML header, skipping"
)
skipped_files += 1
continue

parts = content.split("---", 2)
if len(parts) < 3:
print(
f" Warning: {qmd_file.name} has malformed YAML header, skipping"
)
skipped_files += 1
continue

yaml_header = parts[1]
Expand All @@ -370,15 +356,15 @@ def inject_original_filename_in_qmd_files(docs_dir="origin_DOCS"):
with open(qmd_file, "w", encoding="utf-8") as file:
file.write(new_content)

print(
f" Added original-filename: {original_filename_field} to {qmd_file.name}"
)
processed_files += 1

except Exception as e:
print(f" Error processing {qmd_file.name}: {e}")
skipped_files += 1

print(f"Processed {processed_files} QMD files with original filename injection.")
print(f"Processed {processed_files} QMD files successfully.")
if skipped_files > 0:
print(f"Skipped {skipped_files} files due to errors or missing headers.")


def update_bibliography_paths_before_regroup(
Expand All @@ -394,6 +380,7 @@ def update_bibliography_paths_before_regroup(

processed_projects = 0
processed_qmd_files = 0
moved_bib_files = 0

for project_dir in docs_path.iterdir():
if not project_dir.is_dir() or project_dir.name in EXCLUDED_DOCS_DIRS:
Expand Down Expand Up @@ -430,14 +417,18 @@ def update_bibliography_paths_before_regroup(
for qmd_file in qmd_files:
if update_qmd_bibliography_reference(qmd_file, new_bib_reference):
processed_qmd_files += 1
print(f" Updated {qmd_file.name}")

# Move .bib file to new location
shutil.copy2(original_bib, new_bib_path)
print(f" Moved {original_bib.name} -> {new_bib_path}")
moved_bib_files += 1

processed_projects += 1

if processed_projects > 0:
print(
f"Processed {processed_projects} projects: updated {processed_qmd_files} files, moved {moved_bib_files} bibliography files."
)


def update_qmd_bibliography_reference(qmd_file_path, new_bib_reference):
try:
Expand Down Expand Up @@ -480,10 +471,8 @@ def update_qmd_bibliography_reference(qmd_file_path, new_bib_reference):
with open(qmd_file_path, "w", encoding="utf-8") as file:
file.write(new_content)

print(f" {old_bib_ref} -> {new_bib_reference}")
return True
else:
print(f" No bibliography field in YAML header, skipping")
return False

except Exception as e:
Expand Down
Loading
Loading