@@ -119,8 +119,54 @@ jobs:
119119 Deploy from GHA: ${{ github.event.pull_request.title || format('manual from PR {0}', github.event.issue.number) }}
120120 alias : deploy-preview-${{ github.event.pull_request.number || github.event.issue.number }}
121121 # these all default to 'true'
122- enable-pull-request-comment : true
122+ enable-pull-request-comment : false
123123 enable-commit-comment : false
124124 enable-commit-status : true
125125 overwrites-pull-request-comment : false
126126 timeout-minutes : 1
127+
128+ - name : Get changed files
129+ id : changed-files
130+ uses :
tj-actions/[email protected] 131+ with :
132+ files : |
133+ # don't consider modifications on file used for includes for now.
134+ docs/**/[^_]*.qmd
135+ docs/**/[^_]*.md
136+ json : true
137+
138+ - name : Create custom PR comment
139+ if : github.event.pull_request || github.event.issue.pull_request
140+ uses : actions/github-script@v7
141+ env :
142+ DEPLOY_URL : ${{ steps.netlify-deploy.outputs.deploy-url }}
143+ CHANGED_FILES : ${{ steps.changed-files.outputs.all_changed_files }}
144+ with :
145+ github-token : ${{ secrets.GITHUB_TOKEN }}
146+ script : |
147+ const prNumber = context.payload.pull_request?.number || context.payload.issue.number;
148+ const deployUrl = process.env.DEPLOY_URL;
149+ const changedFiles = JSON.parse(process.env.CHANGED_FILES);
150+
151+ let commentBody = `## 📝 Preview Deployment\n\n`;
152+ commentBody += `🔍 Full site preview: [${deployUrl}](${deployUrl})\n\n`;
153+
154+ if (changedFiles.length > 0) {
155+ commentBody += `### 🔄 Modified Documents\n\n`;
156+ changedFiles.forEach(file => {
157+ if (file.endsWith('.qmd') || file.endsWith('.md')) {
158+ // Convert path to URL (removing file extension and adding appropriate path)
159+ const fileUrlPath = file
160+ .replace(/\.(qmd|md)$/, '.html');
161+ const fileUrl = `${deployUrl}/${fileUrlPath}`;
162+ commentBody += `- [${file}](${fileUrl})\n`;
163+ }
164+ });
165+ }
166+
167+ github.rest.issues.createComment({
168+ issue_number: prNumber,
169+ owner: context.repo.owner,
170+ repo: context.repo.repo,
171+ body: commentBody
172+ });
0 commit comments