File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed
Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ require ( 'dotenv' ) . config ( ) ;
2+ const { Octokit } = require ( '@octokit/rest' ) ;
3+ const axios = require ( 'axios' ) ;
4+
5+ const {
6+ GH_TOKEN : githubToken ,
7+ } = process . env ;
8+
9+ const octokit = new Octokit ( { auth : `token ${ githubToken } ` } ) ;
10+
11+ const url = 'https://raw.githubusercontent.com/zoo-js/zoo-data/main/json/organizations.json' ;
12+ let organizations = [ ] ;
13+
14+ const repo = 'zoo' ;
15+
16+ async function main ( ) {
17+ if ( organizations . length == 0 ) {
18+ console . log ( 'org 0' ) ;
19+ return false ;
20+ }
21+
22+ for ( let i = 0 ; i < organizations . length ; i ++ ) {
23+ let owner = organizations [ i ] . fullName
24+ await octokit . repos . delete ( {
25+ owner,
26+ repo
27+ } )
28+ await octokit . repos . createFork ( {
29+ owner : 'zoo-js' ,
30+ repo,
31+ organization : owner
32+ } )
33+ console . log ( `${ owner } done` )
34+ }
35+ } ;
36+
37+ async function getOrganizations ( ) {
38+ try {
39+ const res = await axios . get ( url ) ;
40+ organizations = res . data . data ;
41+ } catch ( err ) {
42+ console . log ( err ) ;
43+ }
44+ } ;
45+
46+ ( async ( ) => {
47+ await getOrganizations ( ) ;
48+ await main ( ) ;
49+ } ) ( ) ;
You can’t perform that action at this time.
0 commit comments