File tree 4 files changed +7
-70
lines changed
4 files changed +7
-70
lines changed Original file line number Diff line number Diff line change 12
12
pull-requests : write
13
13
contents : read
14
14
15
-
16
15
steps :
17
16
- name : Checkout Repository
18
17
uses : actions/checkout@v4
@@ -30,23 +29,27 @@ jobs:
30
29
31
30
const mdFiles = prFiles.data.filter(file => file.filename.endsWith('.md')).map(file => file.filename);
32
31
33
- if(! mdFiles){
32
+ if(mdFiles.length === 0 ){
34
33
github.rest.issues.createComment({
35
34
issue_number: context.issue.number,
36
35
owner: context.repo.owner,
37
36
repo: context.repo.repo,
38
37
body: 'No Markdown files detected'
39
38
});
39
+ return;
40
40
}
41
41
42
42
const basePath = "https://chtc.github.io/article-preview?url=";
43
43
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}`);
44
44
45
45
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({
47
48
issue_number: context.issue.number,
48
49
owner: context.repo.owner,
49
50
repo: context.repo.repo,
50
51
body: `${commentBody}`
51
- });
52
+ });
53
+ }
54
+
52
55
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