mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-12-16 05:19:43 +01:00
Enhance CyberPanel functionality with FTP Quota and Bandwidth Management features: Added models, views, and templates for managing FTP quotas and bandwidth resets. Implemented IP blocking functionality with associated views and templates. Updated system scripts for improved repository synchronization and OS detection. Removed outdated workflow files.
This commit is contained in:
162
.github/workflows/advanced-repo-sync.yml
vendored
162
.github/workflows/advanced-repo-sync.yml
vendored
@@ -1,162 +0,0 @@
|
||||
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
|
||||
120
.github/workflows/repo-sync.yml
vendored
120
.github/workflows/repo-sync.yml
vendored
@@ -1,120 +0,0 @@
|
||||
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
|
||||
94
.github/workflows/sync2gitee.yml
vendored
94
.github/workflows/sync2gitee.yml
vendored
@@ -1,34 +1,70 @@
|
||||
name: sync2gitee
|
||||
name: Sync to Gitee
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '**'
|
||||
pull_request:
|
||||
branches:
|
||||
- '**'
|
||||
create:
|
||||
branches:
|
||||
- '**'
|
||||
delete:
|
||||
branches:
|
||||
- '**'
|
||||
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:
|
||||
env:
|
||||
dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
|
||||
dst_token: ${{ secrets.GITEE_TOKEN }}
|
||||
gitee_user: ${{ secrets.GITEE_USER }}
|
||||
sync-to-gitee:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: sync github -> gitee
|
||||
uses: Yikun/hub-mirror-action@master
|
||||
if: env.dst_key && env.dst_token && env.gitee_user
|
||||
with:
|
||||
src: 'github/${{ github.repository_owner }}'
|
||||
dst: 'gitee/${{ secrets.GITEE_USER }}'
|
||||
dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
|
||||
dst_token: ${{ secrets.GITEE_TOKEN }}
|
||||
static_list: ${{ github.event.repository.name }}
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
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 || echo "Failed to fetch from Gitee, continuing..."
|
||||
|
||||
- name: Sync branches to Gitee
|
||||
run: |
|
||||
# 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, creating from origin"
|
||||
git checkout -b $branch origin/$branch || continue
|
||||
fi
|
||||
|
||||
# Ensure we're on the latest from origin
|
||||
git fetch origin $branch
|
||||
git reset --hard origin/$branch
|
||||
|
||||
# Push to Gitee with force to resolve conflicts
|
||||
echo "Pushing $branch to Gitee..."
|
||||
git push gitee $branch --force || echo "Failed to push $branch"
|
||||
done
|
||||
|
||||
- name: Sync tags to Gitee
|
||||
run: |
|
||||
# Push all tags to Gitee
|
||||
git push gitee --tags --force || echo "Failed to push some tags"
|
||||
|
||||
- name: Clean up
|
||||
run: |
|
||||
git remote remove gitee || true
|
||||
Reference in New Issue
Block a user