@@ -186,11 +186,22 @@ jobs:
186186 path : kek_validation_results/
187187 retention-days : 30
188188
189+ - name : Generate Token
190+ id : app-token
191+ if : steps.changed-files.outputs.has_changes == 'true' && always()
192+ continue-on-error : true
193+ uses : actions/create-github-app-token@v3
194+ with :
195+ app-id : ${{ vars.MU_ACCESS_APP_ID }}
196+ private-key : ${{ secrets.MU_ACCESS_APP_PRIVATE_KEY }}
197+ owner : ${{ github.repository_owner }}
198+
189199 - name : Comment on PR
190- if : steps.changed-files.outputs.has_changes == 'true' && failure()
200+ if : steps.changed-files.outputs.has_changes == 'true' && failure() && steps.app-token.outputs.token
191201 continue-on-error : true
192202 uses : actions/github-script@v7
193203 with :
204+ github-token : ${{ steps.app-token.outputs.token }}
194205 script : |
195206 const fs = require('fs');
196207 const marker = '<!-- kek-validation-comment -->';
@@ -221,3 +232,33 @@ jobs:
221232 } catch (error) {
222233 core.warning(`Unable to post PR comment: ${error.message}`)
223234 }
235+
236+ - name : Update PR Comment on Success
237+ if : steps.changed-files.outputs.has_changes == 'true' && success() && steps.app-token.outputs.token
238+ continue-on-error : true
239+ uses : actions/github-script@v7
240+ with :
241+ github-token : ${{ steps.app-token.outputs.token }}
242+ script : |
243+ const marker = '<!-- kek-validation-comment -->';
244+ try {
245+ const { data: comments } = await github.rest.issues.listComments({
246+ owner: context.repo.owner,
247+ repo: context.repo.repo,
248+ issue_number: context.issue.number
249+ });
250+ const existing = comments.find(c => c.body.includes(marker));
251+ if (existing) {
252+ const body = marker + '\n\u2705 **KEK Validation Passed**\n\n'
253+ + 'All KEK update files have valid cryptographic signatures.\n\n'
254+ + '_Updated: ' + new Date().toISOString() + '_';
255+ await github.rest.issues.updateComment({
256+ owner: context.repo.owner,
257+ repo: context.repo.repo,
258+ comment_id: existing.id,
259+ body
260+ });
261+ }
262+ } catch (error) {
263+ core.warning(`Unable to update PR comment: ${error.message}`)
264+ }
0 commit comments