Skip to content

Commit

Permalink
Merge branch 'ubq-main' into ubq-development
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlementlegen committed Feb 3, 2025
2 parents 4bf9459 + e2e8fbc commit 63c8b3b
Show file tree
Hide file tree
Showing 6 changed files with 1,859 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"handl",
"sonarjs",
"mischeck",
"unassigns"
"unassigns",
"disqualifier"
],
"dictionaries": ["typescript", "node", "software-terms"],
"import": ["@cspell/dict-typescript/cspell-ext.json", "@cspell/dict-node/cspell-ext.json", "@cspell/dict-software-terms"],
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
env:
APP_ID: ${{ secrets.APP_ID }}
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}
APP_INSTALLATION_ID: ${{ secrets.APP_INSTALLATION_ID }}

jobs:
run-cron:
Expand Down
1,831 changes: 1,831 additions & 0 deletions bun.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"open-source"
],
"dependencies": {
"@octokit/auth-app": "^7.1.4",
"@octokit/graphql-schema": "^15.25.0",
"@octokit/rest": "^21.0.2",
"@sinclair/typebox": "0.34.3",
Expand Down
26 changes: 23 additions & 3 deletions src/cron/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import { createAppAuth } from "@octokit/auth-app";
import { Octokit } from "@octokit/rest";
import { customOctokit } from "@ubiquity-os/plugin-sdk/octokit";
import { Logs } from "@ubiquity-os/ubiquity-os-logger";
import db from "./database-handler";

async function main() {
const logger = new Logs(process.env.LOG_LEVEL ?? "info");
const octokit = new Octokit({
auth: process.env.GITHUB_TOKEN,
authStrategy: createAppAuth,
auth: {
appId: Number(process.env.APP_ID),
privateKey: process.env.APP_PRIVATE_KEY,
installationId: process.env.APP_INSTALLATION_ID,
},
});

const fileContent = db.data;
for (const [key, value] of Object.entries(fileContent)) {
try {
Expand All @@ -15,22 +23,34 @@ async function main() {
value,
});
const [owner, repo] = key.split("/");
const installation = await octokit.rest.apps.getRepoInstallation({
owner,
repo,
});
const comment = value.pop();
if (!comment) {
logger.error(`No comment was found for repository ${key}`);
continue;
}
const repoOctokit = new customOctokit({
authStrategy: createAppAuth,
auth: {
appId: Number(process.env.APP_ID),
privateKey: process.env.APP_PRIVATE_KEY,
installationId: installation.data.id,
},
});
const {
data: { body = "" },
} = await octokit.rest.issues.getComment({
} = await repoOctokit.rest.issues.getComment({
owner,
repo,
comment_id: comment.commentId,
issue_number: comment.issueNumber,
});
const newBody = body + `\n<!-- daemon-disqualifier update ${Date().toLocaleString()} -->`;
logger.debug(`Update comment ${comment.commentId}`, { newBody });
await octokit.rest.issues.updateComment({
await repoOctokit.rest.issues.updateComment({
owner,
repo,
comment_id: comment.commentId,
Expand Down

0 comments on commit 63c8b3b

Please sign in to comment.