Skip to content

Commit 5c0a696

Browse files
committed
Fix comment-on-pr
test test test test Delete test md files
1 parent ecf0366 commit 5c0a696

File tree

4 files changed

+7
-70
lines changed

4 files changed

+7
-70
lines changed

.github/workflows/comment-on-pr.yml

+7-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ jobs:
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

2017-06-02-test.md

-64
This file was deleted.

images/1.md

-1
This file was deleted.

images/2.md

-1
This file was deleted.

0 commit comments

Comments
 (0)