forked from ipdxco/unified-github-workflows
-
Notifications
You must be signed in to change notification settings - Fork 0
33 lines (31 loc) · 1.06 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
name: Sync forks
on:
workflow_dispatch:
jobs:
sync:
name: Sync forks
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.UCI_GITHUB_TOKEN }}
- name: Sync forks
uses: actions/github-script@v6
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})`);
}
}