Skip to content

Commit 46c9b4a

Browse files
EMaherCopilot
andcommitted
fix: use dynamic lookback window based on last [Doc Drift] issue
Instead of hard-coding 'last 7 days', the workflow now queries for the most recent [Doc Drift] issue creation date and uses that as the lookback window. Falls back to 7 days if no prior issues exist. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent b684bee commit 46c9b4a

1 file changed

Lines changed: 30 additions & 4 deletions

File tree

.github/workflows/doc-freshness.md

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,38 @@ safe-outputs:
2424
max: 0
2525

2626
steps:
27+
- name: Determine lookback window
28+
id: lookback
29+
env:
30+
GH_TOKEN: ${{ github.token }}
31+
run: |
32+
# Find the most recent [Doc Drift] issue creation date; fall back to 7 days
33+
LAST_DRIFT_DATE=$(gh issue list \
34+
--repo "$GITHUB_REPOSITORY" \
35+
--search '[Doc Drift] in:title' \
36+
--state all \
37+
--json createdAt \
38+
--jq '.[0].createdAt' 2>/dev/null || echo "")
39+
40+
if [ -z "$LAST_DRIFT_DATE" ] || [ "$LAST_DRIFT_DATE" = "null" ]; then
41+
SINCE_DATE=$(date -u -d '7 days ago' '+%Y-%m-%dT%H:%M:%SZ' 2>/dev/null \
42+
|| date -u -v-7d '+%Y-%m-%dT%H:%M:%SZ')
43+
echo "No prior [Doc Drift] issues found — defaulting to last 7 days"
44+
else
45+
SINCE_DATE="$LAST_DRIFT_DATE"
46+
echo "Last [Doc Drift] issue created at: $SINCE_DATE"
47+
fi
48+
49+
echo "since_date=$SINCE_DATE" >> "$GITHUB_OUTPUT"
50+
2751
- name: Gather recent commits
2852
id: commits
2953
run: |
30-
# Fetch commits from the last 7 days on main
31-
git log origin/main --since="7 days ago" --oneline --name-only > /tmp/gh-aw/recent-commits.txt
54+
# Fetch commits since last doc-drift issue (or last 7 days)
55+
SINCE="${{ steps.lookback.outputs.since_date }}"
56+
git log origin/main --since="$SINCE" --oneline --name-only > /tmp/gh-aw/recent-commits.txt
3257
echo "commit_file=recent-commits.txt" >> "$GITHUB_OUTPUT"
58+
echo "Commits since: $SINCE ($(wc -l < /tmp/gh-aw/recent-commits.txt) lines)"
3359
3460
- name: Gather CLI help output
3561
id: help
@@ -100,7 +126,7 @@ steps:
100126
101127
USER_EOF
102128
103-
echo "## Recent Commits (last 7 days)" >> /tmp/gh-aw/agent/user-context.md
129+
echo "## Recent Commits (since ${{ steps.lookback.outputs.since_date }})" >> /tmp/gh-aw/agent/user-context.md
104130
echo '```' >> /tmp/gh-aw/agent/user-context.md
105131
cat /tmp/gh-aw/recent-commits.txt >> /tmp/gh-aw/agent/user-context.md
106132
echo '```' >> /tmp/gh-aw/agent/user-context.md
@@ -142,7 +168,7 @@ not been updated — and file advisory issues for maintainer review.
142168

143169
Work from **source changes toward documentation**, not the reverse:
144170

145-
1. Read the recent commits from `/tmp/gh-aw/agent/user-context.md` to understand what changed.
171+
1. Read the recent commits from `/tmp/gh-aw/agent/user-context.md` to understand what changed since the last doc-freshness run.
146172
2. For each behavioral change (new command, new flag, changed default, removed feature, new dependency, config change), check if the relevant documentation reflects the current state.
147173
3. Read the actual documentation files (README.md, CONTRIBUTING.md, docs/*, specs/*) to verify accuracy.
148174
4. Read the CLI help output from the user context to compare against documented flags and options.

0 commit comments

Comments
 (0)