diff options
| author | JP Dillingham <jp@dillingham.me> | 2025-11-27 10:52:29 -0600 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2025-11-27 10:52:29 -0600 |
| commit | fd35d5cdb9283a65ec34d2010cd9ec1562f15c98 (patch) | |
| tree | a7dcd903e1c2bcee41e518515636b5493141ce13 /.github/workflows/mirror.yml | |
| parent | af6b985648c96e4fd35525597b94b251e4aa8d45 (diff) | |
| download | slskd-fd35d5cdb9283a65ec34d2010cd9ec1562f15c98.tar.gz | |
tweak mirror
Diffstat (limited to '.github/workflows/mirror.yml')
| -rw-r--r-- | .github/workflows/mirror.yml | 56 |
1 files changed, 38 insertions, 18 deletions
diff --git a/.github/workflows/mirror.yml b/.github/workflows/mirror.yml index 3747426b..132c4d7c 100644 --- a/.github/workflows/mirror.yml +++ b/.github/workflows/mirror.yml @@ -7,6 +7,25 @@ on: delete: branches: - '**' # Trigger when branches are deleted + workflow_dispatch: # Allow manual triggering from GitHub UI + inputs: + target: + description: 'Target to mirror to' + required: false + default: 'all' + type: choice + options: + - all + - GitLab + - Codeberg + delay: + description: 'Delay in seconds before mirroring' + required: false + default: '0' + +concurrency: + group: mirror-sync + cancel-in-progress: false jobs: mirror: @@ -23,7 +42,13 @@ jobs: fail-fast: false # Continue with other mirrors even if one fails steps: + - name: Wait for things to settle + run: | + echo "⏳ Waiting 15 seconds..." + sleep 15 + - name: Checkout repository + if: github.event_name != 'delete' # Skip checkout for delete events uses: actions/checkout@v4 with: fetch-depth: 0 # Fetch full history for proper mirroring @@ -57,21 +82,16 @@ jobs: - name: Mirror to ${{ matrix.target.name }} run: | - echo "🔄 Syncing to ${{ matrix.target.name }}..." - # Add remote with SSH - git remote add mirror ${{ matrix.target.repo }} - - # Push all branches and tags - git push mirror --all --force - git push mirror --tags --force - - echo "✅ Successfully synced to ${{ matrix.target.name }}" - - - name: Handle branch deletion on ${{ matrix.target.name }} - if: github.event_name == 'delete' && github.event.ref_type == 'branch' - run: | - DELETED_BRANCH="${{ github.event.ref }}" - echo "🗑️ Branch '$DELETED_BRANCH' was deleted, syncing deletion to ${{ matrix.target.name }}..." - - # Delete branch from mirror - git push ${{ matrix.target.repo }} --delete "$DELETED_BRANCH" || echo "Branch may not exist on ${{ matrix.target.name }}"
\ No newline at end of file + echo "🔄 Mirroring repository to ${{ matrix.target.name }}..." + + # Clone the GitHub repository as a mirror (bare repo with all refs) + git clone --mirror https://github.com/${{ github.repository }}.git mirror-repo + cd mirror-repo + + # Set the push URL to the target repository + git remote set-url --push origin ${{ matrix.target.repo }} + + # Push everything to the mirror (handles all branches, tags, and deletions) + git push --mirror + + echo "✅ Successfully mirrored to ${{ matrix.target.name }}"
\ No newline at end of file |
