All checks were successful
Update README with ADR Index / update-readme (push) Successful in 6s
- Add Gitea Action to auto-update README badges and ADR table on push - Standardize 8 ADRs from heading-style to inline metadata format - Add shields.io badges for ADR counts (total/accepted/proposed) - Replace static directory listing with linked ADR table in README - Accept ADR-0030 (MFA/YubiKey strategy)
109 lines
4.0 KiB
YAML
109 lines
4.0 KiB
YAML
name: Update README with ADR Index
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- 'decisions/**.md'
|
|
- '.gitea/workflows/update-adr-readme.yaml'
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
update-readme:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 1
|
|
|
|
- name: Generate ADR table and update README
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
TABLE_HEADER="| # | Decision | Status | Date |"
|
|
TABLE_SEPARATOR="|---|----------|--------|------|"
|
|
TABLE_ROWS=""
|
|
TOTAL=0
|
|
ACCEPTED=0
|
|
PROPOSED=0
|
|
SUPERSEDED=0
|
|
DEPRECATED=0
|
|
|
|
for file in decisions/[0-9][0-9][0-9][0-9]-*.md; do
|
|
[ -f "$file" ] || continue
|
|
|
|
# Extract ADR number from filename
|
|
num=$(basename "$file" | grep -oP '^\d+')
|
|
|
|
# Skip the template
|
|
[ "$num" = "0000" ] && continue
|
|
|
|
# Parse title from first heading line
|
|
title=$(head -1 "$file" | sed 's/^#\s*//')
|
|
|
|
# Parse status: "* Status: accepted"
|
|
status=$(grep -m1 -iP '^\*\s*Status:\s*' "$file" \
|
|
| sed 's/^\*\s*Status:\s*//i' | xargs)
|
|
|
|
# Parse date: "* Date: 2026-02-04"
|
|
date=$(grep -m1 -iP '^\*\s*Date:\s*' "$file" \
|
|
| sed 's/^\*\s*Date:\s*//i' | xargs)
|
|
|
|
# Status emoji
|
|
case "$(echo "$status" | tr '[:upper:]' '[:lower:]')" in
|
|
accepted) badge="✅" ; ACCEPTED=$((ACCEPTED+1)) ;;
|
|
proposed) badge="📝" ; PROPOSED=$((PROPOSED+1)) ;;
|
|
superseded*) badge="♻️" ; SUPERSEDED=$((SUPERSEDED+1)) ;;
|
|
deprecated) badge="⛔" ; DEPRECATED=$((DEPRECATED+1)) ;;
|
|
*) badge="❓" ;;
|
|
esac
|
|
|
|
TOTAL=$((TOTAL+1))
|
|
TABLE_ROWS="${TABLE_ROWS}| ${num} | [${title}](${file}) | ${badge} ${status} | ${date} |\n"
|
|
done
|
|
|
|
# Build the full table block
|
|
ADR_TABLE=$(printf '%s\n%s\n%s' "$TABLE_HEADER" "$TABLE_SEPARATOR" "$(echo -e "$TABLE_ROWS")")
|
|
|
|
# Build badge line (shields.io static badge)
|
|
BADGE_LINE="  "
|
|
|
|
# Replace the ADR badges marker
|
|
if grep -q '<!-- ADR-BADGES-START -->' README.md; then
|
|
sed -i '/<!-- ADR-BADGES-START -->/,/<!-- ADR-BADGES-END -->/c\<!-- ADR-BADGES-START -->\n'"${BADGE_LINE}"'\n<!-- ADR-BADGES-END -->' README.md
|
|
else
|
|
echo "::warning::Missing <!-- ADR-BADGES-START --> marker in README.md"
|
|
fi
|
|
|
|
# Replace the ADR table marker
|
|
if grep -q '<!-- ADR-TABLE-START -->' README.md; then
|
|
# Use awk to replace content between markers (handles multi-line)
|
|
awk -v table="$ADR_TABLE" '
|
|
/<!-- ADR-TABLE-START -->/ { print; print table; skip=1; next }
|
|
/<!-- ADR-TABLE-END -->/ { skip=0 }
|
|
!skip { print }
|
|
' README.md > README.md.tmp && mv README.md.tmp README.md
|
|
else
|
|
echo "::warning::Missing <!-- ADR-TABLE-START --> marker in README.md"
|
|
fi
|
|
|
|
# Update the "Last updated" date
|
|
TODAY=$(date +%Y-%m-%d)
|
|
sed -i "s|^\*Last updated:.*\*$|*Last updated: ${TODAY}*|" README.md
|
|
|
|
- name: Check for changes
|
|
id: changes
|
|
run: |
|
|
git diff --quiet README.md && echo "changed=false" >> "$GITHUB_OUTPUT" || echo "changed=true" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Commit and push
|
|
if: steps.changes.outputs.changed == 'true'
|
|
run: |
|
|
git config user.name "Gitea Actions"
|
|
git config user.email "actions@daviestechlabs.io"
|
|
git add README.md
|
|
git commit -m "docs: auto-update ADR index in README [skip ci]"
|
|
git push
|