-
Notifications
You must be signed in to change notification settings - Fork 9
36 lines (34 loc) · 1.14 KB
/
sync-forks.yml
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
28
29
30
31
32
33
34
35
36
name: Sync forks
on:
workflow_dispatch:
schedule:
# https://crontab.guru/#0_22_*_*_1
- cron: "0 22 * * 1"
jobs:
sync:
name: Sync forks
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.UCI_GITHUB_TOKEN }}
- name: Sync forks
uses: actions/github-script@v7
with:
github-token: ${{ secrets.UCI_GITHUB_TOKEN }}
script: |
const forks = await github.paginate(github.rest.repos.listForks, {
owner: context.repo.owner,
repo: context.repo.repo,
});
for (const fork of forks) {
console.log(`Syncing ${fork.full_name} (${fork.clone_url})`);
await exec.exec(`git remote add ${fork.full_name} ${fork.clone_url}`);
try {
await exec.exec(`git push ${fork.full_name} +refs/tags/*:refs/tags/* +refs/remotes/origin/*:refs/heads/*`);
} catch(e) {
console.warn(`Failed to sync ${fork.full_name} (${fork.clone_url})`);
}
}