Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions .github/scripts/generate-announcement.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
const fs = require("fs");

// ======================================================
// Configuration
// ======================================================

const token = process.env.GITHUB_TOKEN;

const event = JSON.parse(
fs.readFileSync(process.env.GITHUB_EVENT_PATH, "utf8")
);
Comment on lines +7 to +11

const owner = event.repository.owner.login;
const repo = event.repository.name;

const API = `https://api.github.com/repos/${owner}/${repo}`;

const headers = {
Authorization: `Bearer ${token}`,
Accept: "application/vnd.github+json"
};

// ======================================================
// GitHub Helpers
// ======================================================

async function githubGet(url) {

const response = await fetch(url, {
headers
});

if (!response.ok) {
throw new Error(
`GitHub GET failed (${response.status}) ${url}`
);
}
Comment on lines +33 to +37

return response.json();
}

// ======================================================
// Main
// ======================================================

(async () => {

console.log("=================================");
console.log("Announcement Generator");
console.log("=================================");

const closedPRs = await githubGet(
`${API}/pulls?state=closed&per_page=100`
);
Comment on lines +52 to +54

const oneWeekAgo = new Date();
oneWeekAgo.setDate(oneWeekAgo.getDate() - 7);

const announcementPRs = closedPRs.filter(pr => {

// Ignore closed but not merged PRs
if (!pr.merged_at) {
return false;
}

// Only last 7 days
const mergedDate = new Date(pr.merged_at);

if (mergedDate < oneWeekAgo) {
return false;
}

// Must have Announcement label
return pr.labels.some(label => label.name === "Announcement");

});

console.log("");
console.log(`Found ${announcementPRs.length} announcement PR(s)\n`);

for (const pr of announcementPRs) {

console.log("---------------------------------------");
console.log(`PR #${pr.number}`);
console.log(`Title : ${pr.title}`);
console.log(`Author : ${pr.user.login}`);
console.log(`Merged : ${pr.merged_at}`);
console.log(`URL : ${pr.html_url}`);

const details = await githubGet(
`${API}/pulls/${pr.number}`
);

console.log("\nDescription:");
console.log(details.body || "(No description)");

const files = await githubGet(
`${API}/pulls/${pr.number}/files`
);
Comment on lines +97 to +99

console.log("\nChanged Files:");

files.forEach(file => {
console.log(` - ${file.filename}`);
});

console.log("");

}

console.log("=================================");
console.log("Finished");
console.log("=================================");

})();
25 changes: 25 additions & 0 deletions .github/workflows/generate-announcement.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Generate Documentation Announcement

on:
workflow_dispatch:

permissions:
contents: read
pull-requests: read

jobs:
generate:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v5

- uses: actions/setup-node@v5
with:
node-version: 24

- name: Generate announcement data
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: node .github/scripts/generate-announcement.js

Loading