From 6f384680b443bf460c3b5ed72f25d9d1f6af1b9c Mon Sep 17 00:00:00 2001 From: Eric Fennis Date: Fri, 4 Jul 2025 17:27:07 +0200 Subject: [PATCH] ci(suggest-tags): Fix failing job --- scripts/suggestTags.mts | 39 +++++++++++++++++++++++++++----------- tools/build-icons/types.ts | 4 ++-- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/scripts/suggestTags.mts b/scripts/suggestTags.mts index fd021f0d1..acfc52e3e 100644 --- a/scripts/suggestTags.mts +++ b/scripts/suggestTags.mts @@ -6,6 +6,7 @@ import { zodTextFormat } from "openai/helpers/zod"; import path from "node:path"; import fs from "node:fs/promises"; import z from "zod"; +import { IconMetadata } from '../tools/build-icons/types'; const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN }); const pullRequestNumber = Number(process.env.PULL_REQUEST_NUMBER); @@ -68,7 +69,7 @@ const suggestionsByFile = changedFiles.map(async ({ filename, raw_url }) => { }, }); - const { tags: suggestedTags } = JSON.parse(response.output_text); + const { tags: suggestedTags }: IconMetadata = JSON.parse(response.output_text); console.log(`Suggesting tags for ${iconName}:`, suggestedTags); @@ -114,6 +115,7 @@ Here are the suggestions: path: filename, line: startLine, body: message, + side: "RIGHT" } }) @@ -124,13 +126,28 @@ if (comments.length === 0) { process.exit(0); } -await octokit.pulls.createReview({ - owner, - repo, - pull_number: pullRequestNumber, - body: `### 🤖 ChatGPT Tags suggestions ✨ -I've asked ChatGPT for some suggestions for tags.`, - event: "COMMENT", - comments, - commit_id: commitSha, -}); +try { + console.log({ + owner, + repo, + pull_number: pullRequestNumber, + body: `### 🤖 ChatGPT Tags suggestions ✨ + I've asked ChatGPT for some suggestions for tags.`, + event: "COMMENT", + comments, + commit_id: commitSha, + }) + await octokit.pulls.createReview({ + owner, + repo, + pull_number: pullRequestNumber, + body: `### 🤖 ChatGPT Tags suggestions ✨ + I've asked ChatGPT for some suggestions for tags.`, + event: "COMMENT", + comments, + commit_id: commitSha, + }); +} catch (error) { + console.error('Error creating review:', error); + process.exit(0); +} diff --git a/tools/build-icons/types.ts b/tools/build-icons/types.ts index d20023407..af39b077e 100644 --- a/tools/build-icons/types.ts +++ b/tools/build-icons/types.ts @@ -30,9 +30,9 @@ export type IconDeprecationReason = 'icon.brand' | ''; export type IconMetadataBase = { toBeRemovedInVersion?: string; - categories?: string[]; + categories: string[]; aliases?: (string | AliasDeprecation)[]; - tags?: string[]; + tags: string[]; deprecationReason?: IconDeprecationReason; deprecated?: boolean; };