Instantly share code, notes, and snippets.
Last activeJanuary 6, 2023 06:28
Save azu/533a1cfb83e1040d77b6963c9004856d to your computer and use it in GitHub Desktop.
Revisions
azu revised this gist
Jan 5, 2023 .1 changed file with0 additions and2 deletions.There are no files selected for viewing
2 changes: 0 additions & 2 deletionsall-env-circleci.mjsThis 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 charactersOriginal file line number Diff line number Diff line change @@ -13,8 +13,6 @@ const fetchProjectEnv = (orgName, project) => { }).then(res=>res.json()); } constprojectNames=awaitfetchProjectList(); constprojectMap=newMap() for(constprojectNameofprojectNames){ constenv=awaitfetchProjectEnv(ORG_NAME,projectName); azu revised this gist
Jan 5, 2023 .1 changed file with1 addition and1 deletion.There are no files selected for viewing
2 changes: 1 addition & 1 deletionall-env-circleci.mjsThis 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ importfetchfrom"node-fetch";// Node.js 18 just remove line constCIRCLECI_TOKEN=process.env.CIRCLECI_TOKEN constORG_NAME=process.env.ORG_NAME azu created this gist
Jan 5, 2023 .There are no files selected for viewing
24 changes: 24 additions & 0 deletionsall-env-circleci.mjsThis 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ importfetchfrom"node-fetch"; constCIRCLECI_TOKEN=process.env.CIRCLECI_TOKEN constORG_NAME=process.env.ORG_NAME constfetchProjectList=(orgName=ORG_NAME)=>{ returnfetch(`https://circleci.com/api/v2/insights/gh/${orgName}/summary`,{ headers:{"Circle-Token":`${CIRCLECI_TOKEN}`} }).then(res=>res.json()).then(json=>json.all_projects); }; constfetchProjectEnv=(orgName,project)=>{ returnfetch(`https://circleci.com/api/v2/project/gh/${orgName}/${project}/envvar`,{ headers:{"Circle-Token":`${CIRCLECI_TOKEN}`} }).then(res=>res.json()); } constprojectNames=awaitfetchProjectList(); console.log(projectNames.length); constprojectMap=newMap() for(constprojectNameofprojectNames){ constenv=awaitfetchProjectEnv(ORG_NAME,projectName); projectMap.set(projectName,env.items); } console.log(JSON.stringify(Array.from((projectMap.entries()))))