fix(workflow): sequential updates with cleanup on failure

- Run nix-update sequentially instead of parallel to avoid race conditions
- Clean up uncommitted changes after failed updates (git checkout/clean)
- Simplify push logic by removing stash/pop complexity
- Remove upload-artifact@v4 (unsupported on Gitea Actions)
This commit is contained in:
m3tm3re
2026-02-09 19:12:22 +01:00
parent 3c87721011
commit 62ce3dc646
2 changed files with 21 additions and 71 deletions

View File

@@ -173,6 +173,11 @@ jobs:
return 0
fi
fi
# Clean up any uncommitted changes from failed update
git checkout -- . 2>/dev/null || true
git clean -fd 2>/dev/null || true
echo "::endgroup::"
if ! grep -q "already up to date\|No new version found" /tmp/update-${pkg}.log; then
@@ -222,34 +227,16 @@ jobs:
echo "📦 Found $(echo $UPDATABLE_PACKAGES | wc -w) updatable packages"
echo ""
# Parallel updates with 4 concurrent jobs
MAX_JOBS=4
JOB_COUNT=0
SUCCESS_LIST=()
for pkg in $UPDATABLE_PACKAGES; do
(run_update "$pkg" && echo "$pkg" >> /tmp/success.txt || true) &
JOB_COUNT=$((JOB_COUNT + 1))
# Wait if we hit max concurrent jobs
if [ $JOB_COUNT -ge $MAX_JOBS ]; then
wait
JOB_COUNT=0
if run_update "$pkg"; then
UPDATES_FOUND=true
if [ -n "$UPDATED_PACKAGES" ]; then
UPDATED_PACKAGES="$UPDATED_PACKAGES, $pkg"
else
UPDATED_PACKAGES="$pkg"
fi
fi
done
# Wait for remaining jobs
wait
# Parse results
if [ -f /tmp/success.txt ]; then
SUCCESS_LIST=$(cat /tmp/success.txt | tr '\n' ' ')
UPDATED_PACKAGES=$(echo "$SUCCESS_LIST" | sed 's/ /, /g' | sed 's/, $//')
UPDATES_FOUND=true
fi
rm -f /tmp/success.txt
fi
COMMIT_COUNT=$(git rev-list --count origin/master..HEAD)
@@ -321,7 +308,6 @@ jobs:
cd "$REPO_DIR"
PACKAGES="${{ steps.update.outputs.updated_packages }}"
# Add opencode to packages list if it was updated
if [ "${{ steps.update-opencode.outputs.opencode_update }}" = "true" ]; then
if [ -n "$PACKAGES" ]; then
PACKAGES="$PACKAGES, opencode"
@@ -334,43 +320,18 @@ jobs:
echo "Current commit: $(git rev-parse HEAD)"
echo "Pending commits: $(git rev-list --count origin/master..HEAD)"
# Clean working directory before rebase
if [ "$(git status --porcelain)" != "" ]; then
echo "::warning::Working directory has uncommitted changes, stashing..."
git stash push -u -m "workflow-temp-changes" || {
echo "::error::Failed to stash changes, aborting"
exit 1
}
echo "::notice::Changes stashed successfully"
fi
echo ""
echo "Pulling latest changes (rebase)..."
if git pull --rebase origin master; then
echo "✅ Rebase successful"
# Unstash changes after successful rebase
if git stash list | grep -q "workflow-temp-changes"; then
echo "::notice::Restoring stashed changes..."
git stash pop || {
echo "::warning::Failed to restore stash, continuing with clean state"
git stash drop stash@{0} || true
}
fi
else
echo "⚠️ Rebase failed, attempting force push..."
echo "⚠️ Rebase failed, resetting and retrying..."
git rebase --abort 2>/dev/null || true
git reset --hard origin/master
git push --force-with-lease origin master
echo "✓ Force push completed"
echo "❌ Could not rebase, updates lost. Will retry next run."
exit 0
fi
# Pre-push validation: ensure clean state
if [ "$(git status --porcelain)" != "" ]; then
echo "::error::Working directory not clean after operations, aborting push"
exit 1
fi
echo ""
echo "Pushing changes to master..."
git push origin master
@@ -379,17 +340,6 @@ jobs:
echo "✅ Successfully pushed updates for: $PACKAGES"
echo "::endgroup::"
- name: Upload Build Logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: build-logs-${{ github.run_number }}
path: |
/tmp/update-*.log
/tmp/build-*.log
/tmp/opencode-build.log
retention-days: 7
- name: Cleanup
if: always()
run: |