Skip to content

Commit

Permalink
sync gh
Browse files Browse the repository at this point in the history
  • Loading branch information
goenning committed Jan 16, 2024
1 parent eaf7562 commit 37a2165
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
19 changes: 9 additions & 10 deletions autogen/projects.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,14 @@
"issue": 3,
"images": [],
"reviews": [],
"reactions": []
"reactions": [
{
"login": "goenning",
"content": "+1",
"avatar_url": "https://avatars.githubusercontent.com/u/94755?v=4",
"created_at": "2024-01-16T08:59:52Z"
}
]
},
{
"id": "doks",
Expand Down Expand Up @@ -179,17 +186,9 @@
"login": "goenning",
"avatar_url": "https://avatars.githubusercontent.com/u/94755?v=4",
"html_url": "https://github.com/aptakube/kubedir/issues/1#issuecomment-1888238084",
"rating": 3,
"rating": 5,
"body": "Very good, I love this service!\r\nI have used it for many years.",
"created_at": "2024-01-12T01:15:25Z"
},
{
"login": "goenning",
"avatar_url": "https://avatars.githubusercontent.com/u/94755?v=4",
"html_url": "https://github.com/aptakube/kubedir/issues/1#issuecomment-1888820978",
"rating": 4,
"body": "Excelent!",
"created_at": "2024-01-12T10:19:44Z"
}
],
"reactions": [
Expand Down
12 changes: 7 additions & 5 deletions scripts/sync-github.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ async function createIssue(title, body) {
return issue;
}

async function updateIssueBody(issueNumber, body) {
async function updateIssueBody(issueNumber, title, body) {
const issue = await gitHubRequest(
"PATCH",
`/repos/aptakube/kubedir/issues/${issueNumber}`,
{
title,
body,
}
);
Expand Down Expand Up @@ -71,7 +72,8 @@ const projects = listProjects();
for (const project of projects) {
console.log(`Processing ${project.name}.`);

const issueBody = `Project: ${project.url}
const issueBody = `ID: ${project.id}
Project: ${project.url}
1️⃣ **Like this project?** Upvote this issue with a 👍 reaction
Expand All @@ -83,11 +85,11 @@ Upvotes and reviews may take up to 1 hour before showing up on [kubedir.com](htt
☸️`;

let issue = issues.find((i) => i.title === project.name);
let issue = issues.find((i) => i.body.startsWith(`ID: ${project.id}`));
if (issue) {
if (issue.body !== issueBody) {
if (issue.body !== issueBody || issue.title !== project.name) {
console.log(`❌ Issue is out-of-date, updating...`);
await updateIssueBody(issue.number, issueBody);
await updateIssueBody(issue.number, project.name, issueBody);
console.log(`✅ Updated issue #${issue.number}`);
}
} else {
Expand Down

0 comments on commit 37a2165

Please sign in to comment.