-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Dj Walker-Morgan <[email protected]>
- Loading branch information
Showing
5 changed files
with
194 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.envrc | ||
node_modules |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Mergeq | ||
|
||
Utility which reads the docs github repo and finds any PRs which have been merged but not yet published in production release. It then generates a list of PRs with their titles, to assist generating the PR for a production release. | ||
|
||
## Usage | ||
|
||
From the docs root: | ||
|
||
```bash | ||
$ tools/user/mergeq/mergeq.js | ||
``` | ||
|
||
This will output a list of PRs which have been merged but not yet published in a production release. | ||
|
||
|
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#! /usr/bin/env node | ||
import fetch from "node-fetch"; | ||
|
||
// Replace with your details | ||
const owner = "enterprisedb"; | ||
const repo = "docs"; | ||
const token = ""; /*process.env.GITHUB_TOKEN*/ // Optional - if we ever need to make authenticated requests | ||
|
||
async function getLatestReleaseDate(owner, repo, token) { | ||
const url = `https://api.github.com/repos/${owner}/${repo}/releases/latest`; | ||
const headers = token ? { Authorization: `token ${token}` } : {}; | ||
const response = await fetch(url, { headers }); | ||
if (!response.ok) { | ||
throw new Error(`Error fetching latest release: ${response.statusText}`); | ||
} | ||
const data = await response.json(); | ||
return new Date(data.published_at); | ||
} | ||
|
||
async function getMergedPullRequestsSince(owner, repo, sinceDate, token) { | ||
const url = `https://api.github.com/repos/${owner}/${repo}/pulls`; | ||
const headers = token ? { Authorization: `token ${token}` } : {}; | ||
const params = new URLSearchParams({ | ||
state: "closed", | ||
base: "develop", | ||
sort: "updated", | ||
direction: "desc", | ||
}); | ||
const response = await fetch(`${url}?${params.toString()}`, { headers }); | ||
if (!response.ok) { | ||
throw new Error(`Error fetching pull requests: ${response.statusText}`); | ||
} | ||
const pulls = await response.json(); | ||
const mergedPulls = pulls.filter( | ||
(pr) => pr.merged_at && new Date(pr.merged_at) > sinceDate, | ||
); | ||
var finalpulls = mergedPulls.map((pr) => `#${pr.number} : ${pr.title}`); | ||
return finalpulls; | ||
} | ||
|
||
async function main() { | ||
try { | ||
const latestReleaseDate = await getLatestReleaseDate(owner, repo, token); | ||
const pulls = await getMergedPullRequestsSince( | ||
owner, | ||
repo, | ||
latestReleaseDate, | ||
token, | ||
); | ||
for (const pull of pulls) { | ||
console.log(pull); | ||
} | ||
console.log(); | ||
console.log( | ||
`Number of merged pull requests since the last release: ${pulls.length}`, | ||
); | ||
} catch (error) { | ||
console.error("Error fetching data from GitHub API:", error); | ||
} | ||
} | ||
|
||
main(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "mergeq", | ||
"version": "1.0.0", | ||
"description": "Calculate the backlog of Merged PRs since last production builds", | ||
"main": "mergeq.js", | ||
"type": "module", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"node-fetch": "^3.3.2" | ||
} | ||
} |
9933d26
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 Published on https://edb-docs-staging.netlify.app as production
🚀 Deployed on https://66fa615564540afe8a1f2a20--edb-docs-staging.netlify.app