primer / octicons

A scalable set of icons handcrafted with <3 by GitHub
https://primer.style/foundations/icons
MIT License
8.22k stars 829 forks source link

[Feedback] Publish icon list as part of the build process #986

Closed rfearing closed 4 months ago

rfearing commented 10 months ago

Describe the topic

I've created an app that allows Contentful users to select an octicon as a dropdown option. I've created a weekly action to check the local list of octicons against the latest list in @primer/octicons. I propose that a list be provided as part of the octicons build process. As reference, this is the action I've created:

name: Validate Octicon List

# Run the Monday of each week:
on:
  schedule:
    - cron: '0 0 * * 1'

jobs:
  validate:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      # Take the local list of octicons, sort them and make a comma separated list of them
      - name: Extract local icons
        id: extract_local
        uses: actions/github-script@v6
        with:
          result-encoding: string
          script: |
            const fs = require('fs');
            const localOcticons = require('./apps/octicons/src/locations/octicons.js').octicons
              .sort().map(icon => icon.replace(/.*\/(.*)-16\.svg/, '$1')
              .replace(/-/g, '_'));
            return localOcticons;

      # Take the list of svg files with -16.svg,
      # remove the path and the -16.svg
      # then replace - with _ and sort them
      # Make a comma separated list of them
      - name: Extract official icons
        id: extract_official
        run: |
          npm install @primer/octicons
          officialOcticons=$(ls node_modules/@primer/octicons/build/svg/*-16.svg | sed 's/.*\///; s/-16\.svg//' | sed 's/-/_/g' | sort -u | tr '\n' ','s | sed 's/,$//')
          echo "officialOcticons=${officialOcticons}" >> $GITHUB_OUTPUT

      # Compare the two lists and output for .md file
      - name: Compare icons
        id: compare_octicons
        uses: actions/github-script@v6
        with:
          result-encoding: string
          script: |
            const localOcticons = "${{ steps.extract_local.outputs.result }}".trim().split(',');
            const officialOcticons = "${{ steps.extract_official.outputs.officialOcticons }}".trim().split(',');
            const mismatched = [...localOcticons, ...officialOcticons].filter(icon => !officialOcticons.includes(icon) || !localOcticons.includes(icon));
            if (mismatched.length > 0) {
              return mismatched.join('\n- ');
            } else {
              return 'no mismatches';
            }

      # If there is a mismatch, create an issue and assign it to marketing-platform-services
      - name: Create issue
        id: create_issue
        if: ${{ steps.compare_octicons.outputs.result != 'no mismatches' }}
        uses: JasonEtco/create-an-issue@v2
        with:
          filename: .github/octicons-issue-template.md
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          MISMATCH: ${{ steps.compare_octicons.outputs.result}}
github-actions[bot] commented 4 months ago

Hi! This issue has been marked as stale because it has been open with no activity for 180 days. You can comment on the issue or remove the stale label to keep it open. If you do nothing, this issue will be closed in 7 days.