diff --git a/.github/workflows/diff-design-tokens.yml b/.github/workflows/diff-design-tokens.yml
index 6675c0024..2d5fd1528 100644
--- a/.github/workflows/diff-design-tokens.yml
+++ b/.github/workflows/diff-design-tokens.yml
@@ -21,20 +21,25 @@ jobs:
with:
script: |
core.setOutput('diffs', `[{
- "title": "## Design Token Diff (CSS)",
+ "title": "Design Token Diff (CSS)",
"folder": "dist/css",
"globString": "**/**/*.css",
"outputFile": "diff_css.json"
},{
- "title": "## Design Token Diff (StyleLint)",
+ "title": "Design Token Diff (StyleLint)",
"folder": "dist/styleLint",
"globString": "**/**/*.json",
"outputFile": "diff_style_lint.json"
},{
- "title": "## Design Token Diff (Figma)",
+ "title": "Design Token Diff (Figma)",
"folder": "dist/figma",
"globString": "**/**/*.json",
"outputFile": "diff_figma.json"
+ },{
+ "title": "Design Token Diff (Fallbacks)",
+ "folder": "dist/fallbacks",
+ "globString": "**/**/*.json",
+ "outputFile": "diff_fallbacks.json"
}]`)
diff:
diff --git a/.github/workflows/utilities/addComment.cjs b/.github/workflows/utilities/addComment.cjs
index 194270b76..6a26201b4 100644
--- a/.github/workflows/utilities/addComment.cjs
+++ b/.github/workflows/utilities/addComment.cjs
@@ -1,10 +1,9 @@
+const findCommentByContent = (searchContent, comments) => {
+ return comments.filter(comment => comment.body.includes(searchContent));
+}
+
module.exports = async ({title, body, sections}, summaryLink, context, github) => {
- // get comments
- const {data: comments} = await github.rest.issues.listComments({
- issue_number: context.issue.number,
- owner: context.repo.owner,
- repo: context.repo.repo
- });
+ console.log(`Preparing comment content for ${title}`)
// prepare body
let commentBody = ''
if(title) {
@@ -30,24 +29,49 @@ module.exports = async ({title, body, sections}, summaryLink, context, github) =
commentBody = `## ${title}\n\nThe message is too long to be displayed here. For more details, please check the job summary.`
}
+ // get comments
+ const {data: comments} = await github.rest.issues.listComments({
+ issue_number: context.issue.number,
+ owner: context.repo.owner,
+ repo: context.repo.repo
+ });
+
+ console.log(`Found ${comments.length} comments`)
// get comment if exists
- const existingComment = comments.filter(comment => comment.body.includes(`## ${title}`));
- // if comment exists, update it
- if(existingComment.length > 0) {
- await github.rest.issues.updateComment({
- comment_id: existingComment[0].id,
- owner: context.repo.owner,
- repo: context.repo.repo,
- body: commentBody
- })
+ const existingComment = findCommentByContent(`## ${title}`, comments);
+ console.log(`Found ${existingComment.length} comments, with the title "## ${title}"`)
+ // delete comment if no body or sections
+ if(!body && (!sections || sections.length === 0)) {
+ if(existingComment.length > 0 &&) {
+ console.log(`Deleting comment with the title "## ${title}" and the id ${existingComment[0].id}`)
+ // if comment exists, delete it
+ await github.rest.issues.deleteComment({
+ comment_id: existingComment[0].id,
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ })
+ }
+ return
}
+
// if comment does not exist, create it
- else {
+ if(existingComment.length === 0) {
+ console.log(`Creating comment with the title "## ${title}"`)
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody
})
+ return
}
+
+ // if comment exists, update it
+ console.log(`Updating comment with the title "## ${title}" and the id ${existingComment[0].id}`)
+ await github.rest.issues.updateComment({
+ comment_id: existingComment[0].id,
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ body: commentBody
+ })
}
diff --git a/.github/workflows/utilities/addSummary.cjs b/.github/workflows/utilities/addSummary.cjs
index bbd3af650..b52108ad5 100644
--- a/.github/workflows/utilities/addSummary.cjs
+++ b/.github/workflows/utilities/addSummary.cjs
@@ -7,14 +7,19 @@ module.exports = (content, overwrite = false) => {
// core.summary.clear()
for (const {title, body, sections} of content) {
+ // if no body or sections, skip
+ if(!body && (!sections || sections.length === 0)) {
+ continue
+ }
+ // add heading
if(title) {
core.summary.addHeading(title, '1')
}
-
+ // add body
if(body) {
core.summary.addRaw(body, true)
}
-
+ // add sections
if(sections) {
sections.forEach(({title, body}) => {
const section = `${title}
\n\n`+