スクリプトを実行してい.sh
ますが、ローカルで問題なく実行されます ( sh /Users/Me/Documents/development/MyRepo/localizable.sh
)。
ただし、Github アクションに追加すると、許可が拒否されます。
正確なエラー:
Run chmod +x localizable.sh
chmod +x localizable.sh
export LOCALIZATION_OUTPUT=$(bash ./localizable.sh)
export LOCALIZATION_OUTPUT="${LOCALIZATION_OUTPUT//'%'/'%25'}"
export LOCALIZATION_OUTPUT="${LOCALIZATION_OUTPUT//$'n'/'%0A'}"
export LOCALIZATION_OUTPUT="${LOCALIZATION_OUTPUT//$'<NL>'/'%0A'}"
export LOCALIZATION_OUTPUT="${LOCALIZATION_OUTPUT//$''/'%0A'}"
export LOCALIZATION_OUTPUT="${LOCALIZATION_OUTPUT//$'\r'/'%0D'}"
echo $(cat output.txt)
echo "::set-output name=message::$LOCALIZATION_OUTPUT"
shell: /bin/bash -e {0}
./localizable.sh: line 38: MyProject/Localizations/en.lproj/Localizable.strings: Permission denied
grep: Unmatched ( or \(
grep: Unmatched ( or \(
./localizable.sh: line 50: done: command not found
./localizable.sh: line 38: MyProject/Localizations/en.lproj/Localizable.strings: Permission denied
grep: Unmatched ( or \(
.sh ファイルは次のようになります。
#!/bin/sh
if [[ -z $lang ]]
then
lang="en"
fi
searchDir="MyProject/Localizations/$lang.lproj"
echo "*Verifying NSLocalizationStrings in "$searchDir"*"
output=$(grep -R NSLocalizedString . --include="*.swift")
count=$(( 0 ))
missing=$(( 0 ))
unusable=$(( 0 ))
OIFS="${IFS}"
NIFS=$'\n'
IFS="${NIFS}"
echo "Entering Loop ${output}"
for LINE in ${output} ; do
echo "loop entered"
IFS="${OIFS}"
quotes=`echo $LINE | awk -F\" '{ for(i=2; i<=NF; i=i+2){ a = a"\\""$i"\\"""^";} {print a; a="";}}'`
key=`echo $quotes | cut -f1 -d"^"`
# 1. Issues with extracting keys if \[\[ -z $key \]\]
if [[ -z $key ]]
then
(( unusable += 1 ))
echo "Couldn't extract key: " $LINE
fi
keyLength=$(echo ${#key})
# 2. Issues with keys that are too long
if [ $keyLength -gt 79 ]
then
(( unusable += 1 ))
echo "Key too long ("$keyLength"): " $key
fi
keyString=$key" ="
found=$(iconv -sc -f UTF-16 -t UTF-8
"$searchDir/Localizable.strings" | grep "$keyString")
if [[ -z $found ]]
then
found=$(grep -r "$keyString" "$searchDir"/ --include=*.strings)
fi
if [[ -z $found ]]
then
(( missing += 1 ))
echo "<NL>**Missing**: \`$key\` from:
<NL>\`\`\`swift<NIL>$LINE<NL>\`\`\`"
fi
(( count += 1 ))
IFS="${NIFS}" done IFS="${OIFS}"
done
IFS="${OIFS}"
echo "<NL>Out of $count keys: <NL>- $unusable not determined<NL>- $missing missing"
if [[ $missing > 0 ]]
then
echo "::set-output name=keys_missing::true" >> output.txt
else echo "::set-output name=keys_missing::false" >> output.txt
fi
これを Github や自分のコンピューター以外の場所で実行するにはどうすればよいですか?