Refine README.md for clarity and consistency: Updated formatting, improved section organization, and clarified installation instructions.
This commit is contained in:
parent
ffaf88d114
commit
11991c0f80
|
|
@ -0,0 +1,162 @@
|
|||
name: Advanced Repository Sync
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, stable, v2.5.5-dev, v2.4.0-dev ]
|
||||
schedule:
|
||||
# Run every 4 hours to keep repositories in sync
|
||||
- cron: '0 */4 * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
advanced-sync:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 45
|
||||
|
||||
steps:
|
||||
- name: Checkout source repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Setup Git configuration
|
||||
run: |
|
||||
git config --global user.name "CyberPanel Sync Bot"
|
||||
git config --global user.email "support@cyberpanel.net"
|
||||
git config --global init.defaultBranch main
|
||||
git config --global pull.rebase false
|
||||
git config --global push.default simple
|
||||
|
||||
- name: Add Gitee remote
|
||||
run: |
|
||||
git remote add gitee https://gitee.com/${{ secrets.GITEE_USER }}/cyberpanel.git
|
||||
|
||||
- name: Fetch all remotes
|
||||
run: |
|
||||
git fetch origin --all --prune
|
||||
git fetch gitee --all --prune || echo "Failed to fetch from Gitee, continuing..."
|
||||
|
||||
- name: Sync specific branches
|
||||
run: |
|
||||
# Function to sync a branch
|
||||
sync_branch() {
|
||||
local branch=$1
|
||||
echo "=== Syncing branch: $branch ==="
|
||||
|
||||
# Check if branch exists locally
|
||||
if git show-ref --verify --quiet refs/heads/$branch; then
|
||||
echo "Branch $branch exists locally, checking out"
|
||||
git checkout $branch
|
||||
else
|
||||
echo "Branch $branch doesn't exist locally, creating from origin"
|
||||
git checkout -b $branch origin/$branch
|
||||
fi
|
||||
|
||||
# Ensure we're on the latest from origin
|
||||
git fetch origin $branch
|
||||
git reset --hard origin/$branch
|
||||
|
||||
# Check if branch exists on Gitee
|
||||
if git show-ref --verify --quiet refs/remotes/gitee/$branch; then
|
||||
echo "Branch $branch exists on Gitee, checking for conflicts"
|
||||
|
||||
# Fetch latest from Gitee
|
||||
git fetch gitee $branch
|
||||
|
||||
# Check if there are differences
|
||||
if ! git diff --quiet HEAD gitee/$branch; then
|
||||
echo "Differences found between local and Gitee $branch"
|
||||
|
||||
# Create a backup branch
|
||||
git branch backup-$branch-$(date +%s) || true
|
||||
|
||||
# Try to merge Gitee changes
|
||||
if git merge gitee/$branch --no-edit --no-ff; then
|
||||
echo "Successfully merged Gitee changes for $branch"
|
||||
else
|
||||
echo "Merge conflict detected for $branch, resolving automatically"
|
||||
|
||||
# Reset to our version (GitHub is source of truth)
|
||||
git reset --hard HEAD
|
||||
git clean -fd
|
||||
|
||||
# Log the conflict for review
|
||||
echo "Conflict resolved by keeping GitHub version for $branch" >> sync-conflicts.log
|
||||
fi
|
||||
else
|
||||
echo "No differences found for $branch"
|
||||
fi
|
||||
else
|
||||
echo "Branch $branch doesn't exist on Gitee, will be created"
|
||||
fi
|
||||
|
||||
# Push to Gitee
|
||||
echo "Pushing $branch to Gitee..."
|
||||
if git push gitee $branch --force-with-lease; then
|
||||
echo "Successfully pushed $branch to Gitee"
|
||||
else
|
||||
echo "Force-with-lease failed, trying force push for $branch"
|
||||
git push gitee $branch --force
|
||||
fi
|
||||
|
||||
echo "=== Completed syncing branch: $branch ==="
|
||||
}
|
||||
|
||||
# Sync main branches
|
||||
sync_branch "main"
|
||||
sync_branch "stable"
|
||||
sync_branch "v2.5.5-dev"
|
||||
sync_branch "v2.4.0-dev"
|
||||
|
||||
# Also sync any other branches that exist
|
||||
for branch in $(git branch -r | grep -v HEAD | sed 's/origin\///' | grep -E '^(v[0-9]+\.[0-9]+\.[0-9]+|dev|beta|alpha)'); do
|
||||
if [[ "$branch" != "main" && "$branch" != "stable" && "$branch" != "v2.5.5-dev" && "$branch" != "v2.4.0-dev" ]]; then
|
||||
sync_branch "$branch"
|
||||
fi
|
||||
done
|
||||
|
||||
- name: Sync all tags
|
||||
run: |
|
||||
echo "=== Syncing tags ==="
|
||||
|
||||
# Get all tags from origin
|
||||
git fetch origin --tags
|
||||
|
||||
# Push all tags to Gitee
|
||||
if git push gitee --tags --force; then
|
||||
echo "Successfully pushed all tags to Gitee"
|
||||
else
|
||||
echo "Failed to push some tags, continuing..."
|
||||
fi
|
||||
|
||||
- name: Verify sync
|
||||
run: |
|
||||
echo "=== Verifying sync ==="
|
||||
|
||||
# Check if main branches exist on Gitee
|
||||
for branch in main stable v2.5.5-dev v2.4.0-dev; do
|
||||
if git show-ref --verify --quiet refs/remotes/gitee/$branch; then
|
||||
echo "✓ Branch $branch exists on Gitee"
|
||||
else
|
||||
echo "✗ Branch $branch missing on Gitee"
|
||||
fi
|
||||
done
|
||||
|
||||
# Show recent commits
|
||||
echo "Recent commits on main:"
|
||||
git log --oneline -5 origin/main || true
|
||||
|
||||
- name: Clean up
|
||||
run: |
|
||||
git remote remove gitee || true
|
||||
rm -f sync-conflicts.log || true
|
||||
|
||||
- name: Upload sync logs
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: sync-logs
|
||||
path: |
|
||||
sync-conflicts.log
|
||||
retention-days: 7
|
||||
|
|
@ -0,0 +1,120 @@
|
|||
name: Repository Sync
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, stable, v2.5.5-dev, v2.4.0-dev ]
|
||||
schedule:
|
||||
# Run every 6 hours to keep repositories in sync
|
||||
- cron: '0 */6 * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
repo-sync:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
|
||||
steps:
|
||||
- name: Checkout source repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0 # Fetch full history
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Configure Git
|
||||
run: |
|
||||
git config --global user.name "CyberPanel Bot"
|
||||
git config --global user.email "support@cyberpanel.net"
|
||||
git config --global init.defaultBranch main
|
||||
|
||||
- name: Add Gitee remote
|
||||
run: |
|
||||
git remote add gitee https://gitee.com/${{ secrets.GITEE_USER }}/cyberpanel.git
|
||||
|
||||
- name: Fetch from Gitee
|
||||
run: |
|
||||
git fetch gitee --all --prune || true
|
||||
|
||||
- name: Sync branches to Gitee
|
||||
run: |
|
||||
# Get current branch
|
||||
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||
echo "Current branch: $CURRENT_BRANCH"
|
||||
|
||||
# List of branches to sync
|
||||
BRANCHES=("main" "stable" "v2.5.5-dev" "v2.4.0-dev")
|
||||
|
||||
for branch in "${BRANCHES[@]}"; do
|
||||
echo "Processing branch: $branch"
|
||||
|
||||
# Check if branch exists locally
|
||||
if git show-ref --verify --quiet refs/heads/$branch; then
|
||||
echo "Branch $branch exists locally"
|
||||
git checkout $branch
|
||||
else
|
||||
echo "Branch $branch doesn't exist locally, checking out from origin"
|
||||
git checkout -b $branch origin/$branch || continue
|
||||
fi
|
||||
|
||||
# Fetch latest changes from origin
|
||||
git fetch origin $branch
|
||||
git reset --hard origin/$branch
|
||||
|
||||
# Check if branch exists on Gitee
|
||||
if git show-ref --verify --quiet refs/remotes/gitee/$branch; then
|
||||
echo "Branch $branch exists on Gitee, attempting to sync"
|
||||
|
||||
# Try to merge or rebase with Gitee changes
|
||||
git fetch gitee $branch || true
|
||||
|
||||
# Check if there are conflicts
|
||||
if git show-ref --verify --quiet refs/remotes/gitee/$branch; then
|
||||
# Try to merge Gitee changes
|
||||
if ! git merge gitee/$branch --no-edit; then
|
||||
echo "Merge conflict detected, resolving automatically"
|
||||
# Reset to our version (GitHub is source of truth)
|
||||
git reset --hard HEAD
|
||||
git clean -fd
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "Branch $branch doesn't exist on Gitee, will be created"
|
||||
fi
|
||||
|
||||
# Push to Gitee with force to resolve conflicts
|
||||
echo "Pushing $branch to Gitee..."
|
||||
git push gitee $branch --force-with-lease || git push gitee $branch --force
|
||||
done
|
||||
|
||||
- name: Sync tags to Gitee
|
||||
run: |
|
||||
# Push all tags to Gitee
|
||||
git push gitee --tags --force || true
|
||||
|
||||
- name: Clean up
|
||||
run: |
|
||||
git remote remove gitee || true
|
||||
|
||||
# Alternative approach using hub-mirror-action with proper configuration
|
||||
mirror-sync:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
if: false # Disabled by default, enable if needed
|
||||
|
||||
steps:
|
||||
- name: Mirror repository to Gitee
|
||||
uses: Yikun/hub-mirror-action@master
|
||||
with:
|
||||
src: github/usmannasir
|
||||
dst: gitee/${{ secrets.GITEE_USER }}
|
||||
dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
|
||||
dst_token: ${{ secrets.GITEE_TOKEN }}
|
||||
account_type: user
|
||||
clone_style: https
|
||||
cache_path: /tmp/hub-mirror-cache
|
||||
force_update: true
|
||||
debug: true
|
||||
timeout: 30m
|
||||
api_timeout: 60
|
||||
lfs: false
|
||||
mappings: |
|
||||
cyberpanel cyberpanel
|
||||
|
|
@ -0,0 +1,164 @@
|
|||
#!/bin/bash
|
||||
|
||||
# CyberPanel Repository Sync Fix Script
|
||||
# This script resolves the current sync conflict between GitHub and Gitee
|
||||
|
||||
set -e
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Configuration
|
||||
GITHUB_REPO="https://github.com/usmannasir/cyberpanel.git"
|
||||
GITEE_REPO="https://gitee.com/qtwrk/cyberpanel.git"
|
||||
TEMP_DIR="/tmp/cyberpanel-sync-$(date +%s)"
|
||||
|
||||
# Function to print colored output
|
||||
print_status() {
|
||||
echo -e "${BLUE}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
print_success() {
|
||||
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
||||
}
|
||||
|
||||
print_warning() {
|
||||
echo -e "${YELLOW}[WARNING]${NC} $1"
|
||||
}
|
||||
|
||||
print_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
# Function to check if command exists
|
||||
command_exists() {
|
||||
command -v "$1" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# Check prerequisites
|
||||
check_prerequisites() {
|
||||
print_status "Checking prerequisites..."
|
||||
|
||||
if ! command_exists git; then
|
||||
print_error "Git is not installed. Please install git first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command_exists ssh; then
|
||||
print_warning "SSH is not available. HTTPS will be used for authentication."
|
||||
fi
|
||||
|
||||
print_success "Prerequisites check completed"
|
||||
}
|
||||
|
||||
# Setup Git configuration
|
||||
setup_git_config() {
|
||||
print_status "Setting up Git configuration..."
|
||||
|
||||
git config --global user.name "CyberPanel Sync Bot"
|
||||
git config --global user.email "support@cyberpanel.net"
|
||||
git config --global init.defaultBranch main
|
||||
git config --global pull.rebase false
|
||||
git config --global push.default simple
|
||||
|
||||
print_success "Git configuration completed"
|
||||
}
|
||||
|
||||
# Clone and sync repositories
|
||||
sync_repositories() {
|
||||
print_status "Starting repository synchronization..."
|
||||
|
||||
# Create temporary directory
|
||||
mkdir -p "$TEMP_DIR"
|
||||
cd "$TEMP_DIR"
|
||||
|
||||
# Clone GitHub repository
|
||||
print_status "Cloning GitHub repository..."
|
||||
git clone --mirror "$GITHUB_REPO" cyberpanel.git
|
||||
cd cyberpanel.git
|
||||
|
||||
# Add Gitee remote
|
||||
print_status "Adding Gitee remote..."
|
||||
git remote add gitee "$GITEE_REPO"
|
||||
|
||||
# Fetch from Gitee to check current state
|
||||
print_status "Fetching from Gitee..."
|
||||
if git fetch gitee --all --prune; then
|
||||
print_success "Successfully fetched from Gitee"
|
||||
else
|
||||
print_warning "Failed to fetch from Gitee, continuing with force push"
|
||||
fi
|
||||
|
||||
# Push all branches and tags to Gitee
|
||||
print_status "Pushing all branches to Gitee..."
|
||||
if git push gitee --all --force; then
|
||||
print_success "Successfully pushed all branches to Gitee"
|
||||
else
|
||||
print_error "Failed to push branches to Gitee"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
print_status "Pushing all tags to Gitee..."
|
||||
if git push gitee --tags --force; then
|
||||
print_success "Successfully pushed all tags to Gitee"
|
||||
else
|
||||
print_warning "Failed to push some tags to Gitee"
|
||||
fi
|
||||
|
||||
print_success "Repository synchronization completed"
|
||||
}
|
||||
|
||||
# Verify sync
|
||||
verify_sync() {
|
||||
print_status "Verifying synchronization..."
|
||||
|
||||
cd "$TEMP_DIR/cyberpanel.git"
|
||||
|
||||
# Check if main branches exist
|
||||
for branch in main stable v2.5.5-dev v2.4.0-dev; do
|
||||
if git show-ref --verify --quiet "refs/remotes/gitee/$branch"; then
|
||||
print_success "Branch $branch exists on Gitee"
|
||||
else
|
||||
print_error "Branch $branch missing on Gitee"
|
||||
fi
|
||||
done
|
||||
|
||||
# Show recent commits
|
||||
print_status "Recent commits on main branch:"
|
||||
git log --oneline -5 refs/remotes/origin/main || true
|
||||
}
|
||||
|
||||
# Cleanup
|
||||
cleanup() {
|
||||
print_status "Cleaning up temporary files..."
|
||||
|
||||
if [ -d "$TEMP_DIR" ]; then
|
||||
rm -rf "$TEMP_DIR"
|
||||
print_success "Cleanup completed"
|
||||
fi
|
||||
}
|
||||
|
||||
# Main execution
|
||||
main() {
|
||||
print_status "Starting CyberPanel Repository Sync Fix"
|
||||
print_status "========================================"
|
||||
|
||||
# Set up error handling
|
||||
trap cleanup EXIT
|
||||
|
||||
# Execute steps
|
||||
check_prerequisites
|
||||
setup_git_config
|
||||
sync_repositories
|
||||
verify_sync
|
||||
|
||||
print_success "Repository sync fix completed successfully!"
|
||||
print_status "The GitHub Actions workflow should now work properly."
|
||||
}
|
||||
|
||||
# Run main function
|
||||
main "$@"
|
||||
Loading…
Reference in New Issue