fix: replace git stash with cp for commit steps (#121)

The stash-based approach fails when origin/main advances during the workflow run (stash pop conflicts with modified tracked files). Using cp to /tmp and restoring after checkout is simpler and conflict-free. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Juan Manuel Servera committed May 19, 2026 at 17:25 UTC 75e6071b846039e8ae1ee076c3a24390fb9e014c
1 file changed +23 -26
.github/workflows/crawl-and-publish.yml
+23 -26
@@ -123,19 +123,14 @@ jobs:
123 set -euo pipefail
124 git config user.name "github-actions[bot]"
125 git config user.email "github-actions[bot]@users.noreply.github.com"
126 - STASH_REF=$(git stash create --include-untracked --message crawl-data -- data/raw data/snapshots) || STASH_REF=""
126 + # Save crawl output before syncing with remote
127 + cp -r data/raw /tmp/crawl-raw
128 + cp -r data/snapshots /tmp/crawl-snapshots
129 git fetch origin "$DEFAULT_BRANCH"
130 git checkout -B "$DEFAULT_BRANCH" "origin/$DEFAULT_BRANCH"
129 - if [ -n "$STASH_REF" ]; then
130 - git stash store "$STASH_REF" || {
131 - echo "Failed to store stash."
132 - exit 1
133 - }
134 - git stash pop || {
135 - echo "Failed to reapply crawl data after syncing $DEFAULT_BRANCH."
136 - exit 1
137 - }
138 - fi
131 + # Restore crawl output on top of synced branch
132 + cp -r /tmp/crawl-raw/* data/raw/ 2>/dev/null || true
133 + cp -r /tmp/crawl-snapshots/* data/snapshots/ 2>/dev/null || true
134 if git diff --quiet -- data/raw data/snapshots; then
135 echo "No changes to data/raw or data/snapshots. Skipping counter increment."
136 exit 0
@@ -314,13 +309,13 @@ jobs:
309 echo "No analyzed data or token usage changes to commit."
310 exit 0
311 fi
317 - git stash push --include-untracked --message analyzed-data -- data/analyzed data/metrics
312 + cp -r data/analyzed /tmp/analyzed-data
313 + cp -r data/metrics /tmp/metrics-data
314 git fetch origin "$DEFAULT_BRANCH"
315 git checkout -B "$DEFAULT_BRANCH" "origin/$DEFAULT_BRANCH"
320 - git stash pop || {
321 - echo "Failed to reapply analyzed data after syncing $DEFAULT_BRANCH."
322 - exit 1
323 - }
316 + mkdir -p data/analyzed data/metrics
317 + cp -r /tmp/analyzed-data/* data/analyzed/ 2>/dev/null || true
318 + cp -r /tmp/metrics-data/* data/metrics/ 2>/dev/null || true
319 git add data/analyzed/ data/metrics/
320 git diff --cached --quiet || git commit -m "analysis: weekly summary $WEEK"
321 git push origin "HEAD:$DEFAULT_BRANCH" || {
@@ -393,13 +388,15 @@ jobs:
388 echo "No generated content changes to commit."
389 exit 0
390 fi
396 - git stash push --include-untracked --message generated-content -- content/weekly content/monthly content/yearly
391 + cp -r content/weekly /tmp/content-weekly 2>/dev/null || true
392 + cp -r content/monthly /tmp/content-monthly 2>/dev/null || true
393 + cp -r content/yearly /tmp/content-yearly 2>/dev/null || true
394 git fetch origin "$DEFAULT_BRANCH"
395 git checkout -B "$DEFAULT_BRANCH" "origin/$DEFAULT_BRANCH"
399 - git stash pop || {
400 - echo "Failed to reapply generated content after syncing $DEFAULT_BRANCH."
401 - exit 1
402 - }
396 + mkdir -p content/weekly content/monthly content/yearly
397 + cp -r /tmp/content-weekly/* content/weekly/ 2>/dev/null || true
398 + cp -r /tmp/content-monthly/* content/monthly/ 2>/dev/null || true
399 + cp -r /tmp/content-yearly/* content/yearly/ 2>/dev/null || true
400 git add content/weekly/ content/monthly/ content/yearly/
401 git diff --cached --quiet || git commit -m "content: weekly page $WEEK"
402 git push origin "HEAD:$DEFAULT_BRANCH" || {
@@ -651,13 +648,13 @@ jobs:
648 exit 0
649 fi
650
654 - git stash push --include-untracked --message reskill-state -- .squad data/metrics
651 + cp -r .squad /tmp/squad-state
652 + cp -r data/metrics /tmp/reskill-metrics
653 git fetch origin "$DEFAULT_BRANCH"
654 git checkout -B "$DEFAULT_BRANCH" "origin/$DEFAULT_BRANCH"
657 - git stash pop || {
658 - echo "Failed to reapply .squad changes after syncing $DEFAULT_BRANCH."
659 - exit 1
660 - }
655 + cp -r /tmp/squad-state/* .squad/ 2>/dev/null || true
656 + mkdir -p data/metrics
657 + cp -r /tmp/reskill-metrics/* data/metrics/ 2>/dev/null || true
658 git add .squad/ data/metrics/
659 git diff --cached --quiet || git commit -m "chore: reskill state update"
660 git push origin "HEAD:$DEFAULT_BRANCH" || {