Last active
September 2, 2021 15:10
-
-
Save adityak74/a9655bf7eff5879f6db72cd4952c0787 to your computer and use it in GitHub Desktop.
Revisions
-
adityak74 renamed this gist
Sep 2, 2021 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
adityak74 revised this gist
Sep 2, 2021 . 1 changed file with 12 additions and 7 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -18,13 +18,18 @@ async function mergeAllPullRequests() { }).then(async ({ data }) => { for(let i = 0; i < data.length; i++) { console.info('Merging PR', data[i].number); try { const mergeData = await octokit.rest.pulls.merge({ owner: "adityak74", repo: "newfields-app", pull_number: data[i].number, merge_method: "squash" }); console.info(`${mergeData.data.message} with hash : ${mergeData.data.sha}`); } catch (error) { console.error(error); continue; } } }).catch(err => { console.error('Error listing pull requests', err); -
adityak74 created this gist
Sep 2, 2021 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ const { Octokit } = require("octokit"); const dotenv = require('dotenv'); const path = require('path'); // to load the PAT you created dotenv.config({ path: path.join(__dirname, '..', '..', `.env.${process.env.NODE_ENV || 'development'}`) }); // Create a personal access token at https://github.com/settings/tokens/new?scopes=repo const octokit = new Octokit({ auth: process.env.GIT_PAT }); // Compare: https://docs.github.com/en/rest/reference/users#get-the-authenticated-user async function mergeAllPullRequests() { await octokit.rest.users.getAuthenticated(); octokit.rest.pulls.list({ owner: "gitusername", repo: "yourrepo", state: "open" }).then(async ({ data }) => { for(let i = 0; i < data.length; i++) { console.info('Merging PR', data[i].number); const mergeData = await octokit.rest.pulls.merge({ owner: "adityak74", repo: "cryptoviz", pull_number: data[i].number, merge_method: "squash" }); console.info(`${mergeData.data.message} with hash : ${mergeData.data.sha}`); } }).catch(err => { console.error('Error listing pull requests', err); }); } mergeAllPullRequests();