Update Actions to recognize bad libraries #22
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Translations | |
on: | |
workflow_dispatch: | |
pull_request: | |
jobs: | |
string-change-verification: | |
runs-on: ubuntu-latest | |
outputs: | |
changed: ${{ steps.changeDetection.outputs.should-run }} | |
files: ${{ steps.changeDetection.outputs.files }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get changed files | |
id: changed-files | |
uses: tj-actions/changed-files@v44 | |
- name: Verify build.gradle changed | |
id: changeDetection | |
env: | |
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} | |
run: | | |
SEARCH='strings.xml' | |
CHANGEDFILES='' | |
for file in ${ALL_CHANGED_FILES}; do | |
if [[ "$file" == *"$SEARCH" ]]; then | |
echo "$file was changed" | |
CHANGEDFILES="${CHANGEDFILES} $file" | |
echo "should-run=true" >> $GITHUB_OUTPUT | |
fi | |
done | |
echo "files=$CHANGEDFILES" >> $GITHUB_OUTPUT | |
checkTranslations: | |
runs-on: ubuntu-latest | |
needs: string-change-verification | |
if: needs.string-change-verification.outputs.changed == 'true' | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Prepare Profanity Check | |
id: prep | |
run: | | |
sudo apt-get install -y xmlstarlet | |
pip3 install alt-profanity-check | |
chmod +x ./scripts/checkProfanity.py | |
chmod +x ./scripts/generateFilelist.sh | |
FILE_LIST="${{needs.string-change-verification.outputs.files}}" | |
SIZE=$(echo "$FILE_LIST" | awk '{print NF}') | |
if [ "$SIZE" -ne 1 ]; then | |
echo "Only pass the amount of commits and one translation file! You passed: $SIZE" | |
exit 1 | |
fi | |
TRANSLATIONS=$(./scripts/generateFilelist.sh ${{ github.event.pull_request.commits }} ${{needs.string-change-verification.outputs.files}}) | |
echo "TRANSLATIONS=$TRANSLATIONS" >> $GITHUB_OUTPUT | |
shell: sh | |
- uses: fabasoad/translation-action@main | |
id: google-translate | |
with: | |
provider: google | |
lang: auto-en | |
source: ${{ steps.prep.outputs.TRANSLATIONS }} | |
- name: Print the result | |
run: | | |
echo "Translations are: '${{ steps.google-translate.outputs.text }}'" | |
echo "${{ steps.google-translate.outputs.text }}" | sed 's/; /\n/g' > translated_texts.txt | |
cat translated_texts.txt | ./scripts/checkProfanity.sh | |
shell: sh | |
- name: Upload Raw Translations | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Translations | |
path: | | |
changed_texts.txt | |
translated_texts.txt | |
suspicious_texts.txt | |
- name: Fail if there are suspected profanities | |
run: | | |
if [ -s "suspicious_texts.txt" ]; then | |
echo "We found suspicious translations. Please check!" | |
exit 1 | |
fi | |
shell: sh | |