diff --git a/.build/validate-pr.mjs b/.build/validate-pr.mjs index 4d9cb4a15..a51580666 100644 --- a/.build/validate-pr.mjs +++ b/.build/validate-pr.mjs @@ -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) +} diff --git a/.github/workflows/validate-pr.yml b/.github/workflows/validate-pr.yml index e98403f22..8c2da6dba 100644 --- a/.github/workflows/validate-pr.yml +++ b/.github/workflows/validate-pr.yml @@ -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 diff --git a/icons/outline/a-b-2 copy.svg b/icons/outline/a-b-2 copy.svg new file mode 100644 index 000000000..84e7cfe58 --- /dev/null +++ b/icons/outline/a-b-2 copy.svg @@ -0,0 +1,23 @@ + + + + + + + +