Skip to content

Commit 69d5706

Browse files
committed
feedback enhancements
1 parent 7b1a991 commit 69d5706

File tree

2 files changed

+64
-11
lines changed

2 files changed

+64
-11
lines changed

.github/workflows/build-preview.yml

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
jobs:
1212
build-preview:
1313
runs-on: ubuntu-latest
14+
# Temporarily disabled to avoid duplicate comments with pr-preview.yml
15+
# Both workflows provide similar functionality, pr-preview.yml is more comprehensive
16+
if: false
1417
steps:
1518
- name: Checkout code
1619
uses: actions/checkout@v4
@@ -60,27 +63,54 @@ jobs:
6063
uses: actions/github-script@v7
6164
with:
6265
script: |
66+
const prNumber = context.issue.number;
67+
const runId = context.runId;
68+
6369
const comment = `🔨 **Preview Build Complete!**
6470
65-
Your changes have been built successfully. To test locally:
71+
Your changes have been built successfully.
6672
73+
**📦 Download & Test Locally:**
74+
1. [📁 Download Docker Image Artifact](https://github.com/${{ github.repository }}/actions/runs/${runId}) (look for \`wrongsecrets-preview-${prNumber}\`)
75+
2. Load and run the image:
6776
\`\`\`bash
68-
# Download the artifact and load the Docker image
77+
# Download the artifact, extract it, then:
6978
docker load < wrongsecrets-preview.tar
7079
docker run -p 8080:8080 wrongsecrets-preview
7180
\`\`\`
7281
7382
Then visit: http://localhost:8080
7483
75-
**Changed Files in this PR:**
76-
- Templates: ${{ github.event.pull_request.changed_files }}
84+
**📝 Changed Files in this PR:**`;
85+
86+
// Get the list of changed files
87+
const { data: files } = await github.rest.pulls.listFiles({
88+
owner: context.repo.owner,
89+
repo: context.repo.repo,
90+
pull_number: prNumber
91+
});
92+
93+
const templateFiles = files.filter(file =>
94+
file.filename.includes('templates/') ||
95+
file.filename.includes('static/') ||
96+
file.filename.includes('explanations/')
97+
);
98+
99+
let filesList = '';
100+
if (templateFiles.length > 0) {
101+
filesList = templateFiles.map(file => `- \`${file.filename}\``).join('\\n ');
102+
} else {
103+
filesList = '- No template/static files changed';
104+
}
105+
106+
const fullComment = comment + '\\n ' + filesList + `
77107
78108
---
79109
<sub>Build completed by GitHub Actions</sub>`;
80110
81111
github.rest.issues.createComment({
82-
issue_number: context.issue.number,
112+
issue_number: prNumber,
83113
owner: context.repo.owner,
84114
repo: context.repo.repo,
85-
body: comment
115+
body: fullComment
86116
});

.github/workflows/pr-preview.yml

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,33 @@ jobs:
177177
178178
Then visit: http://localhost:8080
179179
180-
**📝 Changes in this PR:**
181-
- Templates and static content updates
182-
- Challenge explanations
183-
- Application logic changes
180+
**📝 Changes in this PR:**`;
181+
182+
// Get the list of changed files
183+
const { data: files } = await github.rest.pulls.listFiles({
184+
owner: context.repo.owner,
185+
repo: context.repo.repo,
186+
pull_number: prNumber
187+
});
188+
189+
const relevantFiles = files.filter(file =>
190+
file.filename.includes('templates/') ||
191+
file.filename.includes('static/') ||
192+
file.filename.includes('explanations/') ||
193+
file.filename.includes('src/main/java/')
194+
);
195+
196+
let filesList = '';
197+
if (relevantFiles.length > 0) {
198+
filesList = relevantFiles.slice(0, 10).map(file => `- \`${file.filename}\``).join('\\n ');
199+
if (relevantFiles.length > 10) {
200+
filesList += `\\n - ... and ${relevantFiles.length - 10} more files`;
201+
}
202+
} else {
203+
filesList = '- No relevant files changed';
204+
}
205+
206+
const finalComment = comment + '\\n ' + filesList + `
184207
185208
Visual diff screenshots will be available shortly...
186209
@@ -191,7 +214,7 @@ jobs:
191214
issue_number: prNumber,
192215
owner: context.repo.owner,
193216
repo: context.repo.repo,
194-
body: comment
217+
body: finalComment
195218
});
196219
197220
visual-diff:

0 commit comments

Comments
 (0)