Skip to content

Commit c6b1819

Browse files
committed
chore(ci): Simplify extension-validation reusing existing actions
Simplify maintenance by leveraging existing GitHub Actions to streamline the process avoiding the need to use custom scripting.
1 parent c787346 commit c6b1819

File tree

1 file changed

+26
-48
lines changed

1 file changed

+26
-48
lines changed

.github/workflows/extension-validation.yml

Lines changed: 26 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ jobs:
7676
$(cat /tmp/validation-reports/changed_files.txt | tr '\n' ' ') \
7777
> /tmp/validation-reports/extension-validation-report.md
7878
79+
echo 'report<<EOF' >> $GITHUB_OUTPUT
80+
cat /tmp/validation-reports/extension-validation-report.md >> $GITHUB_OUTPUT
81+
echo 'EOF' >> $GITHUB_OUTPUT
82+
7983
- name: Combine validation reports and display summary
8084
if: always()
8185
run: |
@@ -109,57 +113,31 @@ jobs:
109113
/tmp/validation-reports/changed_files.txt
110114
retention-days: 30
111115

116+
- name: Find Comment
117+
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && always()
118+
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3.1.0
119+
id: fc
120+
with:
121+
issue-number: ${{ github.event.pull_request.number }}
122+
comment-author: "github-actions[bot]"
123+
body-includes: "<!-- extension-validation-report -->"
124+
112125
- name: Comment PR with report
113126
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && always()
114-
uses: actions/github-script@e69ef5462fd455e02edcaf4dd7708eda96b9eda0 # v7.0.1
127+
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
115128
with:
116-
script: |
117-
const fs = require('fs');
118-
119-
// Check if validation report exists
120-
if (!fs.existsSync('/tmp/validation-reports/validation-report.md')) {
121-
console.log('Validation report not found');
122-
return;
123-
}
124-
125-
const report = fs.readFileSync('/tmp/validation-reports/validation-report.md', 'utf8');
126-
127-
// Find existing comment using the HTML comment marker
128-
const { data: comments } = await github.rest.issues.listComments({
129-
owner: context.repo.owner,
130-
repo: context.repo.repo,
131-
issue_number: context.issue.number,
132-
});
133-
134-
const botComment = comments.find(comment =>
135-
comment.body.includes('<!-- extension-validation-report -->')
136-
);
137-
138-
const commentBody = '<!-- extension-validation-report -->\n' +
139-
'# Extension Validation Report\n\n' +
140-
report + '\n\n' +
141-
'***\n' +
142-
'*This report was automatically generated by the Extension Validation workflow and it is updated automatically when files are modified.*';
143-
144-
if (botComment) {
145-
console.log('Updating existing comment with ID:', botComment.id);
146-
// Update existing comment
147-
await github.rest.issues.updateComment({
148-
owner: context.repo.owner,
149-
repo: context.repo.repo,
150-
comment_id: botComment.id,
151-
body: commentBody
152-
});
153-
} else {
154-
console.log('Creating new comment');
155-
// Create new comment
156-
await github.rest.issues.createComment({
157-
owner: context.repo.owner,
158-
repo: context.repo.repo,
159-
issue_number: context.issue.number,
160-
body: commentBody
161-
});
162-
}
129+
comment-id: ${{ steps.fc.outputs.comment-id }}
130+
issue-number: ${{ github.event.pull_request.number }}
131+
body: |
132+
<!-- extension-validation-report -->
133+
# Extension Validation Report
134+
135+
${{ steps.extension-validation.outputs.report }}
136+
137+
***
138+
139+
*This report was automatically generated by the Extension Validation workflow and it is updated automatically when files are modified.*
140+
edit-mode: replace
163141

164142
- name: Check validation results
165143
if: always()

0 commit comments

Comments
 (0)