Skip to content

MMS icon in O2

MMS icon in O2 #52

Workflow file for this run

name: Check icons keywords
on:
workflow_dispatch:
# push:
# paths:
# - "icons/**"
pull_request:
branches:
- production
paths:
- "icons/**"
jobs:
check-keywords:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: List SVG files
run: |
ICONS_DIR="icons"
echo "Listing SVG files..."
# Use 'find' to get all SVG files in the icons directory
find $ICONS_DIR -type f -name "*.svg" |
# Use 'basemame' to get the file names without the path
xargs -I {} basename {} |
# Use 'sed' to remove the "-filled", "-light", "-regular" parts and the ".svg" extension
sed 's/\(-filled\|-light\|-regular\)\.svg//' |
# Use 'sort -u' to get a unique list of file names
sort -u > icons.txt
# Show the contents of the icons.txt file in the console
cat icons.txt
continue-on-error: false
- name: Read JSON file
run: |
JSON_FILE="icons/icons-keywords.json"
echo "Reading JSON file..."
cat $JSON_FILE > data.json
continue-on-error: true
- name: Extract keywords
run: |
echo "Extracting keywords from JSON..."
# Use 'jq' to extract the keys from the JSON and save them to keywords.txt
cat data.json | jq -r 'keys[]' > keywords.txt
# Show the contents of the keywords.txt file in the console
cat keywords.txt
continue-on-error: true
- name: Compare with Keywords
id: compare
run: |
# echo "Comparing icon names with keywords from JSON..."
missing_keywords=""
for icon_name in $(cat icons.txt); do
if ! grep -q "\"$icon_name\":" data.json; then
missing_keywords="$missing_keywords\n\033[0;31m× $icon_name\033[0m"
fi
done
# Show the complete list of missing elements
if [ -n "$missing_keywords" ]; then
echo -e "\n\033[4mMissing Keywords\033[0m"
echo -e "$missing_keywords \n"
exit 1 # End the execution with an error code
fi
continue-on-error: false
- name: Cleanup
run: |
rm data.json
rm icons.txt
rm keywords.txt
continue-on-error: true