Skip to content

Commit

Permalink
Normalize check actions (#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
yceballost authored Oct 15, 2023
1 parent 60ece0a commit d05df67
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 27 deletions.
30 changes: 19 additions & 11 deletions .github/workflows/evenodd-test.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
name: Search & Destroy evenodds
name: Check evenodds

on:
push:
paths:
- "icons/**"
workflow_dispatch:
# push:
# paths:
# - "icons/**"
pull_request:
branches:
- production
paths:
- "icons/**"

jobs:
build:
check_evenodd:
runs-on: ubuntu-latest

steps:
- name: Buscar palabra en archivos SVG
- name: Checkout del código
uses: actions/checkout@v2

- name: Search for evenodd icons
run: |
ICONS_DIR="icons"
files_with_evenodd=""
for file in $(find icons -name "*.svg"); do
for file in $(find $ICONS_DIR -name "*.svg"); do
if grep -q "evenodd" "$file"; then
# echo "Se encontró la palabra 'evenodd' en $file"
files_with_evenodd="${files_with_evenodd}${file}\n"
# Remove the "icons/" part of the path
file_without_icons="${file#$ICONS_DIR/}"
files_with_evenodd="${files_with_evenodd}\033[0;31m× $file_without_icons\033[0m\n"
fi
done
if [ -n "$files_with_evenodd" ]; then
echo -e "Archivos con 'evenodd':\n${files_with_evenodd}"
exit 1
echo -e "\n\033[4mEvenodd icons\033[0m\n"
echo -e "$files_with_evenodd"
exit 1 # End the execution with an error code
fi
32 changes: 16 additions & 16 deletions .github/workflows/keywords-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ name: Check icons keywords

on:
workflow_dispatch:
push:
paths:
- "icons/**"
# push:
# paths:
# - "icons/**"
pull_request:
branches:
- production
paths:
- "icons/**"

jobs:
check_icons:
check_keywords:
runs-on: ubuntu-latest

steps:
Expand All @@ -21,22 +21,22 @@ jobs:

- name: List SVG files
run: |
ICONS_DIR="icons" # Reemplaza con la ubicación real de tu carpeta de iconos
ICONS_DIR="icons"
echo "Listing SVG files..."
# Utiliza 'find' para encontrar todos los archivos SVG en la carpeta de iconos
# Use 'find' to get all SVG files in the icons directory
find $ICONS_DIR -type f -name "*.svg" |
# Utiliza 'basename' para obtener solo el nombre de archivo sin la ruta
# Use 'basemame' to get the file names without the path
xargs -I {} basename {} |
# Utiliza 'sed' para quitar las partes "-filled", "-light", "-regular" y la extensión ".svg"
# Use 'sed' to remove the "-filled", "-light", "-regular" parts and the ".svg" extension
sed 's/\(-filled\|-light\|-regular\)\.svg//' |
# Utiliza 'sort -u' para obtener una lista única de nombres de archivo
# Use 'sort -u' to get a unique list of file names
sort -u > icons.txt
# Muestra el contenido del archivo icons.txt en la consola
# Show the contents of the icons.txt file in the console
cat icons.txt
continue-on-error: false

Expand All @@ -51,10 +51,10 @@ jobs:
run: |
echo "Extracting keywords from JSON..."
# Usamos jq para extraer las claves del JSON y guardarlas en keywords.txt
# Use 'jq' to extract the keys from the JSON and save them to keywords.txt
cat data.json | jq -r 'keys[]' > keywords.txt
# Mostramos el contenido de keywords.txt para verificar que se han extraído correctamente
# Show the contents of the keywords.txt file in the console
cat keywords.txt
continue-on-error: true

Expand All @@ -65,15 +65,15 @@ jobs:
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 "
missing_keywords="$missing_keywords\n\033[0;31m× $icon_name\033[0m"
fi
done
# Mostrar la lista completa de elementos que faltan
# Show the complete list of missing elements
if [ -n "$missing_keywords" ]; then
echo -e "\n\033[1mMissing Keywords:\033[0m"
echo -e "\n\033[4mMissing Keywords\033[0m"
echo -e "$missing_keywords \n"
exit 1 # Terminar la ejecución con un código de error
exit 1 # End the execution with an error code
fi
continue-on-error: false

Expand Down

0 comments on commit d05df67

Please sign in to comment.