This commit is contained in:
codecalm 2025-12-23 00:09:18 +01:00
parent 2ee77ab914
commit d15fb80beb
3 changed files with 63 additions and 25 deletions

View File

@ -1,28 +1,33 @@
import { execSync } from 'child_process'
import { basename } from 'path'
// Check files added relative to main branch (for PR)
function getAddedFilesFromMain() {
try {
const output = execSync('git diff origin/main...HEAD --name-status', { encoding: 'utf-8' })
const addedFiles = []
output.split('\n').forEach(line => {
if (line.startsWith('A\t')) {
addedFiles.push(line.substring(2))
}
})
return addedFiles
} catch (error) {
// Fallback: check relative to HEAD if origin/main doesn't exist
try {
const output = execSync('git diff --diff-filter=A --name-only', { encoding: 'utf-8' })
return output.trim().split('\n').filter(Boolean)
} catch {
// Check icon files added relative to main branch (for PR)
function getAddedIconsFromMain() {
try {
const output = execSync('git diff origin/main...HEAD --name-status', { encoding: 'utf-8' })
const addedIcons = []
output.split('\n').forEach(line => {
if (line.startsWith('A\t')) {
const filePath = line.substring(2)
// Filter only SVG files from icons/outline/ or icons/filled/ directories
if (filePath.match(/^icons\/(outline|filled)\/.+\.svg$/)) {
const iconName = basename(filePath, '.svg')
addedIcons.push(iconName)
}
}
})
return addedIcons
} catch (error) {
return []
}
}
}
}
const addedFiles = getAddedFilesFromMain()
console.log('Added files:', addedFiles)
const addedIcons = getAddedIconsFromMain()
if (addedIcons.length > 0) {
console.log('Added icons:', addedIcons)
} else {
process.exit(0)
}

View File

@ -55,13 +55,23 @@ jobs:
- name: Validate PR
id: validate-pr
run: pnpm run --silent validate-pr > ./comment-markup.md
run: pnpm run --silent validate-pr > ./comment-markup-pr.md || true
continue-on-error: true
- name: Check if icons were added
id: check-icons
run: |
if [ -s ./comment-markup-pr.md ]; then
echo "has_icons=true" >> $GITHUB_OUTPUT
else
echo "has_icons=false" >> $GITHUB_OUTPUT
fi
- name: Comment PR
if: steps.check-icons.outputs.has_icons == 'true'
uses: thollander/actions-comment-pull-request@v2
with:
filePath: ./comment-markup.md
filePath: ./comment-markup-pr.md
comment_tag: validate-pr
mode: recreate

View File

@ -0,0 +1,23 @@
<!--
category: Text
tags: [test, visual, user, design, a, b, 2]
version: "1.76"
unicode: "f25f"
-->
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M16 21h3c.81 0 1.48 -.67 1.48 -1.48l.02 -.02c0 -.82 -.69 -1.5 -1.5 -1.5h-3v3" />
<path d="M16 15h2.5c.84 -.01 1.5 .66 1.5 1.5s-.66 1.5 -1.5 1.5h-2.5v-3" />
<path d="M4 9v-4c0 -1.036 .895 -2 2 -2s2 .964 2 2v4" />
<path d="M2.99 11.98a9 9 0 0 0 9 9m9 -9a9 9 0 0 0 -9 -9" />
<path d="M8 7h-4" />
</svg>

After

Width:  |  Height:  |  Size: 620 B