@@ -47,10 +47,12 @@ jobs:
47
47
const results = require('./color-contrast-check.json');
48
48
const faildChecks = results.reduce((acc, {failingContrast}) => acc + failingContrast, 0);
49
49
50
+
50
51
// prepare outputs for all failed themes
51
52
const failedResults = results.filter(themeResults => themeResults.failingContrast > 0).map(({theme, failingContrast, markdownTable}) => ({
52
- title: `# ❌ \`${theme}\`: ${failingContrast} checks failed`,
53
+ title: `# ❌ \`${theme}\`: ${failingContrast} checks failed`,
53
54
body: `${markdownTable}`
55
+ identifier: `<!-- contrast check --><!-- Theme: ${theme} -->`
54
56
}))
55
57
56
58
// prepare summary body
@@ -101,6 +103,7 @@ jobs:
101
103
with :
102
104
script : |
103
105
const results = ${{ steps.check-results.outputs.failedResults }}
106
+
104
107
const WORKFLOW_SUMMARY_URL = `https://github.com/${{env.GITHUB_REPOSITORY}}/actions/runs/${{env.GITHUB_RUN_ID}}`
105
108
106
109
// get comments
@@ -110,30 +113,47 @@ jobs:
110
113
repo: context.repo.repo
111
114
});
112
115
113
- for (const {title, body} of results) {
114
- // get token issue
115
- const tokenCheckComment = comments.filter(comment => comment.body.includes(title));
116
- const outputBody = `${title}\n\n${body}\n\n<a href="${WORKFLOW_SUMMARY_URL}">→ Details</a>`
116
+ // get comments of token issues
117
+ let currentComments = comments.filter(comment => possibleTitles.some(titleStart => comment.body.includes(titleStart)));
117
118
118
- // if token issue exists, update it
119
- if(tokenCheckComment.length > 0) {
120
- await github.rest.issues.updateComment({
121
- comment_id: tokenCheckComment[0].id,
119
+ // get token issue
120
+ const tokenCheckComment = comments.filter(comment => comment.body.includes("<!-- contrast check -->"));
121
+
122
+ // if token issue exists, update it
123
+ if(tokenCheckComment.length > 0) {
124
+ for (const comment of tokenCheckComment) {
125
+ await github.rest.issues.deleteComment({
126
+ comment_id: comment.id,
122
127
owner: context.repo.owner,
123
128
repo: context.repo.repo,
124
- body: outputBody
125
129
})
126
130
}
131
+ }
132
+
133
+ for (const {title, body, indentifier} of results) {
134
+ // get token issue
135
+
136
+ const outputBody = `${title}\n\n${body}\n\n<a href="${WORKFLOW_SUMMARY_URL}">→ Details</a>${indentifier}`
127
137
128
138
// if token issue does not exist, create it
129
- else {
130
- await github.rest.issues.createComment({
131
- issue_number: context.issue.number,
139
+ await github.rest.issues.createComment({
140
+ issue_number: context.issue.number,
141
+ owner: context.repo.owner,
142
+ repo: context.repo.repo,
143
+ body: outputBody
144
+ })
145
+ }
146
+
147
+ // if token issue exists, update it
148
+ if(currentComments.length > 0) {
149
+ await currentComments.map(comment => {
150
+ console.log('deleting comment', comment.id, comment)
151
+ github.rest.issues.deleteComment({
152
+ comment_id: comment.id,
132
153
owner: context.repo.owner,
133
154
repo: context.repo.repo,
134
- body: outputBody
135
155
})
136
- }
156
+ })
137
157
}
138
158
139
159
Fail_action_on_contrast_failing :
@@ -165,15 +185,17 @@ jobs:
165
185
});
166
186
167
187
// get token issue
168
- const tokenCheckComment = comments.filter(comment => comment.body.includes('## Design Token Contrast Check' ));
188
+ const tokenCheckComment = comments.filter(comment => comment.body.includes("<!-- contrast check -->" ));
169
189
170
190
// if token issue exists, update it
171
191
if(tokenCheckComment.length > 0) {
172
- await github.rest.issues.deleteComment({
173
- comment_id: tokenCheckComment[0].id,
174
- owner: context.repo.owner,
175
- repo: context.repo.repo,
176
- })
192
+ for (const comment of tokenCheckComment) {
193
+ await github.rest.issues.deleteComment({
194
+ comment_id: comment.id,
195
+ owner: context.repo.owner,
196
+ repo: context.repo.repo,
197
+ })
198
+ }
177
199
}
178
200
179
201
// remove summary
0 commit comments