Skip to content
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
21 changes: 21 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ jobs:
path: website
fetch-depth: 0 # full history required to determine last edit

- name: Fetch full history for submodules
working-directory: website
run: git submodule foreach --recursive "git fetch --unshallow --all 2>/dev/null || git fetch --all"

- name: Inject last_modified_at dates from submodules
working-directory: website
run: bash inject_dates.sh

- name: Fetch - precice develop
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -72,6 +80,19 @@ jobs:
bundler-cache: true
working-directory: website

- name: Patch jekyll-last-modified-at to respect frontmatter
working-directory: website
run: |
set -euo pipefail
shopt -s nullglob
hook_files=(vendor/bundle/ruby/*/gems/jekyll-last-modified-at-*/lib/jekyll-last-modified-at/hook.rb)
if [ "${#hook_files[@]}" -ne 1 ]; then
echo "Expected exactly one jekyll-last-modified-at hook.rb file, found ${#hook_files[@]}:" >&2
printf ' %s\n' "${hook_files[@]}" >&2
exit 1
fi
sed -i 's/item\.data\["last_modified_at"\] = Determinator/item.data["last_modified_at"] ||= Determinator/' "${hook_files[0]}"

- name: Build website
working-directory: website
env:
Expand Down
53 changes: 53 additions & 0 deletions inject_dates.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash
# inject_dates.sh
# Run this from the website root before jekyll build.
# It goes into each submodule, finds every markdown file,
# gets its true last-commit date from git, and injects/updates
# the last_modified_at field in the frontmatter so that
# jekyll-last-modified-at uses the correct date instead of
# falling back to filesystem mtime.

set -euo pipefail

git submodule foreach --recursive '
echo "==> Processing submodule: $displaypath"

git ls-files "*.md" "*.markdown" | while IFS= read -r file; do

last_date=$(git log -1 --date=format:"%Y-%m-%d %H:%M:%S" --pretty=format:"%cd" -- "$file" 2>/dev/null)

if [ -z "$last_date" ]; then
echo " SKIP (no git date): $file"
continue
fi

filepath="$toplevel/$displaypath/$file"

if [ ! -f "$filepath" ]; then
echo " SKIP (not on disk): $file"
continue
fi

if awk '\''NR==1 { if ($0 == "---") { in_front=1; next } else { exit 1 } } in_front && NR>1 && $0 == "---" { exit 0 } END { exit 1 }'\'' "$filepath"; then

if grep -q "^last_modified_at:" "$filepath"; then
sed -i "s|^last_modified_at:.*|last_modified_at: $last_date|" "$filepath"
else
sed -i "0,/^---/{s|^---|---\nlast_modified_at: $last_date|}" "$filepath"
fi

else
tmpfile=$(mktemp)
printf -- "---\nlast_modified_at: %s\n---\n" "$last_date" | cat - "$filepath" > "$tmpfile"
mv "$tmpfile" "$filepath"
fi

echo " OK: $file -> $last_date"

done

echo " done."
'

echo ""
echo "All submodule dates injected successfully."