summaryrefslogtreecommitdiffstats
path: root/.forgejo/workflows/mirror.yml
blob: fd222115acea6e887a25f5c24d70d2311e15cf62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
name: mirror

on:
  workflow_dispatch:

  schedule:
    - cron: '@daily'

jobs:
  mirror:
    if: ${{ secrets.MIRROR_TOKEN != '' }}
    runs-on: docker
    container:
      image: 'code.forgejo.org/oci/node:20-bookworm'
    steps:
      - name: git push {v*/,}forgejo
        run: |
          git init --bare .
          git remote add origin ${{ env.GITHUB_SERVER_URL }}/${{ env.GITHUB_REPOSITORY }}
          git fetch origin refs/heads/forgejo:refs/mirror/forgejo
          git ls-remote origin refs/heads/v*/forgejo | while read sha full_ref ; do
            ref=${full_ref#refs/heads/}
            echo git fetch origin $full_ref:refs/mirror/$ref
            git fetch origin $full_ref:refs/mirror/$ref
          done
          echo git push --force https://${{ vars.MIRROR_DESTINATION }} refs/mirror/*:refs/heads/*
          git push --force https://any:${{ secrets.MIRROR_TOKEN }}@${{ vars.MIRROR_DESTINATION }} refs/mirror/*:refs/heads/*