Files
claude-hub/scripts/setup/setup-claude-backup-cron.sh
MCPClaude 4338059113 Implement wait-for-all-checks PR review trigger to prevent duplicate reviews (#73)
* feat: implement wait-for-all-checks PR review trigger

This change modifies the PR review triggering logic to wait for ALL check suites
to complete successfully before triggering a single PR review, preventing duplicate
reviews from different check suites (build, security scans, etc.).

Key changes:
- Added PR_REVIEW_WAIT_FOR_ALL_CHECKS env var (default: true)
- Added PR_REVIEW_DEBOUNCE_MS for configurable delay (default: 5000ms)
- Implemented checkAllCheckSuitesComplete() function that queries GitHub API
- Made PR_REVIEW_TRIGGER_WORKFLOW optional (only used when wait-for-all is false)
- Updated tests to handle new behavior

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: correct indentation and remove test-results from git

- Fix ESLint indentation errors in claudeService.js
- Remove test-results directory from git tracking (added to .gitignore)

🤖 Generated with Claude Code (https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* feat: add Claude CLI database sharing and backup system

- Mount host ~/.claude directory in container for shared context
- Add .dockerignore to optimize build context
- Create backup script with daily/weekly retention strategy
- Add cron setup for automated backups to /backup partition

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: add missing makeGitHubRequest function to githubService

The checkAllCheckSuitesComplete function was failing because it tried to call
githubService.makeGitHubRequest which didn't exist. This was causing PR reviews
to never trigger with the 'Waiting for other check suites to complete' message.

Added the missing function to make direct GitHub API requests using Octokit.

* fix: add URL validation to makeGitHubRequest to prevent SSRF vulnerability

* refactor: remove makeGitHubRequest to fix SSRF vulnerability

- Replace makeGitHubRequest with getCheckSuitesForRef using Octokit
- Simplify getWorkflowNameFromCheckSuite to use app info from webhook
- Fix tests to match new implementation
- Add PR review environment variables to .env file

---------

Co-authored-by: Jonathan Flatt <jonflatt@gmail.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: ClaudeBot <claude@example.com>
2025-05-26 20:45:59 -05:00

41 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
# Setup cron job for Claude CLI database backups
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BACKUP_SCRIPT="${SCRIPT_DIR}/../utils/backup-claude-db.sh"
# First ensure backup directories exist with proper permissions
echo "Ensuring backup directories exist..."
if [ ! -d "/backup/claude-cli" ]; then
echo "Creating backup directories (requires sudo)..."
sudo mkdir -p /backup/claude-cli/daily /backup/claude-cli/weekly
sudo chown -R $USER:$USER /backup/claude-cli
fi
# Ensure backup script exists and is executable
if [ ! -f "${BACKUP_SCRIPT}" ]; then
echo "Error: Backup script not found at ${BACKUP_SCRIPT}"
exit 1
fi
# Make sure backup script is executable
chmod +x "${BACKUP_SCRIPT}"
# Add cron job (daily at 2 AM)
CRON_JOB="0 2 * * * ${BACKUP_SCRIPT} >> /var/log/claude-backup.log 2>&1"
# Check if cron job already exists
if crontab -l 2>/dev/null | grep -q "backup-claude-db.sh"; then
echo "Claude backup cron job already exists"
else
# Add the cron job
(crontab -l 2>/dev/null; echo "${CRON_JOB}") | crontab -
echo "Claude backup cron job added: ${CRON_JOB}"
fi
# Create log file with proper permissions
sudo touch /var/log/claude-backup.log
sudo chown $USER:$USER /var/log/claude-backup.log
echo "Setup complete. Backups will run daily at 2 AM."
echo "Logs will be written to /var/log/claude-backup.log"