@@ -119,8 +119,55 @@ 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+ escape_json : false
138+
139+ - name : Create custom PR comment
140+ if : github.event.pull_request || github.event.issue.pull_request
141+ uses : actions/github-script@v7
142+ env :
143+ DEPLOY_URL : ${{ steps.netlify-deploy.outputs.deploy-url }}
144+ CHANGED_FILES : ${{ steps.changed-files.outputs.all_changed_files }}
145+ with :
146+ github-token : ${{ secrets.GITHUB_TOKEN }}
147+ script : |
148+ const prNumber = context.payload.pull_request?.number || context.payload.issue.number;
149+ const deployUrl = process.env.DEPLOY_URL;
150+ const changedFiles = JSON.parse(process.env.CHANGED_FILES);
151+
152+ let commentBody = `## 📝 Preview Deployment\n\n`;
153+ commentBody += `🔍 Full site preview: [${deployUrl}](${deployUrl})\n\n`;
154+
155+ if (changedFiles.length > 0) {
156+ commentBody += `### 🔄 Modified Documents\n\n`;
157+ changedFiles.forEach(file => {
158+ if (file.endsWith('.qmd') || file.endsWith('.md')) {
159+ // Convert path to URL (removing file extension and adding appropriate path)
160+ const fileUrlPath = file
161+ .replace(/\.(qmd|md)$/, '.html');
162+ const fileUrl = `${deployUrl}/${fileUrlPath}`;
163+ commentBody += `- [${file}](${fileUrl})\n`;
164+ }
165+ });
166+ }
167+
168+ github.rest.issues.createComment({
169+ issue_number: prNumber,
170+ owner: context.repo.owner,
171+ repo: context.repo.repo,
172+ body: commentBody
173+ });
0 commit comments