Sync Forks #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Sync Forks | |
| on: | |
| schedule: | |
| - cron: "0 10 * * *" | |
| workflow_dispatch: | |
| inputs: | |
| repo: | |
| description: "Repo to sync (empty = all)" | |
| required: false | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Sync forks | |
| env: | |
| GH_TOKEN: ${{ secrets.ORG_PAT }} | |
| run: | | |
| set -euo pipefail | |
| if [ -n "${{ inputs.repo }}" ]; then | |
| repos="ton-python/${{ inputs.repo }}" | |
| else | |
| repos=$(gh repo list ton-python \ | |
| --fork --no-archived --limit 100 \ | |
| --json nameWithOwner -q '.[].nameWithOwner') | |
| fi | |
| if [ -z "$repos" ]; then | |
| echo "No forks found" | |
| exit 0 | |
| fi | |
| failed=0 | |
| while read -r repo; do | |
| echo "Syncing $repo ..." | |
| if ! gh repo sync "$repo" --force 2>&1; then | |
| echo "::warning::Failed to sync $repo" | |
| failed=1 | |
| fi | |
| done <<< "$repos" | |
| if [ "$failed" -eq 1 ]; then | |
| echo "::error::Some repos failed to sync" | |
| exit 1 | |
| fi |