-
Notifications
You must be signed in to change notification settings - Fork 2
59 lines (49 loc) · 1.8 KB
/
Copy pathpr-description.yml
File metadata and controls
59 lines (49 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
name: PR Auto-Check Comment
on:
pull_request:
types: [opened, edited, synchronize]
permissions:
pull-requests: write
contents: read
jobs:
add-comment:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get Changed Files
id: changed-files
run: |
echo "files<<EOF" >> $GITHUB_OUTPUT
git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install Prettier
run: npm install -g prettier
- name: Check Prettier
id: prettier-check
run: |
if npx prettier --check . 2>/dev/null; then
echo "prettier_status=✅ Passed" >> $GITHUB_OUTPUT
else
echo "prettier_status=❌ Failed" >> $GITHUB_OUTPUT
fi
- name: Add PR Comment
uses: actions/github-script@v7
with:
script: |
const changedFiles = `${{ steps.changed-files.outputs.files }}`;
const prettierStatus = `${{ steps.prettier-check.outputs.prettier_status }}`;
const timestamp = new Date().toISOString();
const comment = `## 📋 PR Auto-Check\n\n### 📝 Files Changed\n\`\`\`\n${changedFiles || 'No files changed'}\n\`\`\`\n\n### ✨ Code Quality\n**Prettier Check:** ${prettierStatus}\n\n---\n*Auto-generated on ${timestamp}*`;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: comment
});