File tree Expand file tree Collapse file tree 4 files changed +7
-70
lines changed Expand file tree Collapse file tree 4 files changed +7
-70
lines changed Original file line number Diff line number Diff line change 1212 pull-requests : write
1313 contents : read
1414
15-
1615 steps :
1716 - name : Checkout Repository
1817 uses : actions/checkout@v4
@@ -30,23 +29,27 @@ jobs:
3029
3130 const mdFiles = prFiles.data.filter(file => file.filename.endsWith('.md')).map(file => file.filename);
3231
33- if(! mdFiles){
32+ if(mdFiles.length === 0 ){
3433 github.rest.issues.createComment({
3534 issue_number: context.issue.number,
3635 owner: context.repo.owner,
3736 repo: context.repo.repo,
3837 body: 'No Markdown files detected'
3938 });
39+ return;
4040 }
4141
4242 const basePath = "https://chtc.github.io/article-preview?url=";
4343 const urls = mdFiles.map(file => `${basePath}https://raw.githubusercontent.com/${context.repo.owner}/${context.repo.repo}/refs/heads/${context.payload.pull_request.head.ref}/${file}`);
4444
4545 const commentBody = urls.map(url => `URL to preview article: ${url}`).join("\n\n");
46- github.rest.issues.createComment({
46+ if(commentBody.trim().length > 0){
47+ github.rest.issues.createComment({
4748 issue_number: context.issue.number,
4849 owner: context.repo.owner,
4950 repo: context.repo.repo,
5051 body: `${commentBody}`
51- });
52+ });
53+ }
54+
5255
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments