@@ -29,24 +29,43 @@ runs:
29
29
$([[ -n "${{ inputs.project }}" ]] && echo "--project ${{ inputs.project }}")
30
30
shell : bash
31
31
32
- - name : Upload diffs as artifacts
33
- uses : actions/upload-artifact@v4
34
- with :
35
- name : dashboard-diffs
36
- path : built/
37
-
38
- - name : Post artifacts link to PR
32
+ - name : Post diffs as PR comments
39
33
if : ${{ github.event_name == 'pull_request' }}
40
34
uses : actions/github-script@v7
41
35
with :
42
36
script : |
43
- const runId = process.env.GITHUB_RUN_ID;
44
- const repoUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}`;
45
- const artifactUrl = `${repoUrl}/actions/runs/${runId}`;
46
- const commentBody = `### Dashboard diffs\nThe dashboard diffs can be downloaded from the [workflow artifacts](artifactUrl).`;
37
+ const fs = require('fs');
38
+ const path = require('path');
39
+
40
+ // Directory containing the diff files
41
+ const diffDir = './built';
42
+
43
+ // Filter files to include only those with a `.diff` extension
44
+ const diffFiles = fs.readdirSync(diffDir).filter(file => file.endsWith('.diff'));
45
+
46
+ if (diffFiles.length === 0) {
47
+ console.log('No diff files found to comment.');
48
+ return;
49
+ }
50
+
51
+ // Generate the PR comment with collapsible sections
52
+ let commentBody = `### Dashboard diffs\n\n`;
53
+ for (const file of diffFiles) {
54
+ const diffContent = fs.readFileSync(path.join(diffDir, file), 'utf-8');
55
+ commentBody += `
56
+ <details>
57
+ <summary>Diff for ${file}</summary>
58
+
59
+ \`\`\`diff
60
+ ${diffContent}
61
+ \`\`\`
62
+ </details>\n\n`;
63
+ }
64
+
65
+ // Post the comment
47
66
github.rest.issues.createComment({
48
67
owner: context.repo.owner,
49
68
repo: context.repo.repo,
50
69
issue_number: context.issue.number,
51
- body: commentBody.replace('artifactUrl', artifactUrl)
70
+ body: commentBody.trim() // Ensure no trailing newlines
52
71
});
0 commit comments