From d2157281f37210be0b5f2bd44b72e2f4b544a794 Mon Sep 17 00:00:00 2001 From: Anh Nguyen Date: Mon, 9 Sep 2024 14:22:04 +0700 Subject: [PATCH] try another approach --- .github/workflows/check-localization.yaml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/check-localization.yaml b/.github/workflows/check-localization.yaml index 38d454bd4..a94938f3b 100644 --- a/.github/workflows/check-localization.yaml +++ b/.github/workflows/check-localization.yaml @@ -51,10 +51,17 @@ jobs: jq 'keys' $FILE_PATH | tr -d '[],"' | tr -s ' ' '\n' | while read -r key; do # Debug: Output the key being checked echo "Checking key: $key" - # Search for the key usage - if grep -r "'$key'.tr()" ./lib/**/*.dart; then - echo "| $key | Used |" >> $GITHUB_STEP_SUMMARY + # Escape special characters in the key + escaped_key=$(printf '%s\n' "$key" | sed -e 's/[^^]/[&]/g; s/\^/\\^/g') + + # Search for the key usage, prevent exit on failure with "|| true" + if grep -r "'$escaped_key'.tr()" ./lib/**/*.dart || true; then + if grep -q "'$escaped_key'.tr()" ./lib/**/*.dart; then + echo "| $key | Used |" >> $GITHUB_STEP_SUMMARY + else + echo "| $key | Unused |" >> $GITHUB_STEP_SUMMARY + fi else - echo "| $key | Unused |" >> $GITHUB_STEP_SUMMARY + echo "Error checking key: $key" >> $GITHUB_STEP_SUMMARY fi done \ No newline at end of file