name: Sync upstream
on:
schedule:
- cron: "17 4 * * *"
workflow_dispatch:
permissions:
contents: write
concurrency:
group: sync-upstream
jobs:
sync:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- repo: pocketbase
upstream: pocketbase/pocketbase
- repo: dbx
upstream: pocketbase/dbx
- repo: fexpr
upstream: fexpr/fexpr
- repo: ozzo-validation
upstream: pocketbase/ozzo-validation
- repo: tygoja
upstream: pocketbase/tygoja
name: ${{ matrix.repo }}
steps:
- name: Mirror upstream master and tags
env:
UPSTREAM: https://ganigeorgiev.com/git/${{ matrix.upstream }}
FORK: https://x-access-token:${{ secrets.SYNC_TOKEN }}@github.com/${{ github.repository_owner }}/${{ matrix.repo }}.git
run: |
git init -q mirror
cd mirror
git remote add upstream "$UPSTREAM"
git remote add fork "$FORK"
git fetch --no-tags fork master
git fetch --tags upstream master
git push fork FETCH_HEAD:refs/heads/master
git ls-remote --tags --refs fork | awk '{print $2}' | sort > existing
git for-each-ref --format='%(refname)' refs/tags | sort | comm -23 - existing | xargs -r -n 50 git push fork