@@ -94,27 +94,35 @@ jobs:
9494 run : |
9595 scripts/combine-sponsorships.sh
9696
97- - name : Save history snapshot
98- run : |
99- mkdir -p data/history
100- cp data/all-sponsorships.json data/history/$(date +%F).json
101-
10297 - name : Commit and push history snapshot to history branch
10398 run : |
99+ # Save current data to temp location
100+ SNAPSHOT_DATE=$(date +%F)
101+ TEMP_SNAPSHOT="/tmp/snapshot-${SNAPSHOT_DATE}.json"
102+ cp data/all-sponsorships.json "${TEMP_SNAPSHOT}"
103+
104+ # Configure git
104105 git config --global user.name "github-actions[bot]"
105106 git config --global user.email "github-actions[bot]@users.noreply.github.com"
107+
108+ # Fetch and checkout history branch
106109 git fetch origin history || true
107110 git checkout -B history origin/history || git checkout --orphan history
108- git pull origin history || true
111+
112+ # Create directory and copy snapshot
109113 mkdir -p data/history
110- cp ../data/history/*.json data/history/ 2>/dev/null || true
114+ cp "${TEMP_SNAPSHOT}" "data/history/${SNAPSHOT_DATE}.json"
115+
116+ # Commit and push if there are changes
111117 git add data/history/
112118 if ! git diff --cached --quiet; then
113- git commit -m "chore: add sponsorship snapshot for $(date +%F) "
119+ git commit -m "chore: add sponsorship snapshot for ${SNAPSHOT_DATE} "
114120 git push origin history
115121 else
116122 echo "No new history to commit"
117123 fi
124+
125+ # Return to main branch
118126 git checkout -
119127
120128 - name : Prepare Pages deployment
0 commit comments