mirror of
https://github.com/bitwarden/browser.git
synced 2024-10-31 08:20:37 +01:00
adding logic to gracefully handle scenarios with no crowdin changes (#1126)
This commit is contained in:
parent
b47835df68
commit
55b27d4607
50
.github/workflows/crowdin-sync.yml
vendored
50
.github/workflows/crowdin-sync.yml
vendored
@ -79,6 +79,7 @@ jobs:
|
|||||||
$CROWDIN_BASE_URL/$CROWDIN_PROJECT_ID/translations/builds \
|
$CROWDIN_BASE_URL/$CROWDIN_PROJECT_ID/translations/builds \
|
||||||
-d "{\"branchId\": $CROWDIN_MASTER_BRANCH_ID}" | jq -r '.data.id'
|
-d "{\"branchId\": $CROWDIN_MASTER_BRANCH_ID}" | jq -r '.data.id'
|
||||||
)
|
)
|
||||||
|
echo "[*] Crowin translations build id: $BRANCH_ID"
|
||||||
echo "::set-output name=id::$BUILD_ID"
|
echo "::set-output name=id::$BUILD_ID"
|
||||||
|
|
||||||
- name: Wait for Crowdin build to finish
|
- name: Wait for Crowdin build to finish
|
||||||
@ -113,6 +114,7 @@ jobs:
|
|||||||
curl -s -H "Authorization: Bearer $CROWDIN_API_TOKEN" \
|
curl -s -H "Authorization: Bearer $CROWDIN_API_TOKEN" \
|
||||||
$CROWDIN_BASE_URL/$CROWDIN_PROJECT_ID/translations/builds/$CROWDIN_BUILD_ID/download | jq -r '.data.url'
|
$CROWDIN_BASE_URL/$CROWDIN_PROJECT_ID/translations/builds/$CROWDIN_BUILD_ID/download | jq -r '.data.url'
|
||||||
)
|
)
|
||||||
|
echo "[*] Crowin translations download url: $DOWNLOAD_URL"
|
||||||
echo "::set-output name=value::$DOWNLOAD_URL"
|
echo "::set-output name=value::$DOWNLOAD_URL"
|
||||||
|
|
||||||
- name: Download Crowdin translations
|
- name: Download Crowdin translations
|
||||||
@ -127,27 +129,49 @@ jobs:
|
|||||||
unzip -o $SAVE_FILE
|
unzip -o $SAVE_FILE
|
||||||
rm $SAVE_FILE
|
rm $SAVE_FILE
|
||||||
|
|
||||||
- name: Commit changes
|
- name: Check changes
|
||||||
|
id: files-changed
|
||||||
env:
|
env:
|
||||||
BRANCH_NAME: ${{ steps.branch.outputs.branch-name }}
|
BRANCH_NAME: ${{ steps.branch.outputs.branch-name }}
|
||||||
BRANCH_EXISTS: ${{ steps.branch.outputs.branch-exists }}
|
BRANCH_EXISTS: ${{ steps.branch.outputs.branch-exists }}
|
||||||
run: |
|
run: |
|
||||||
echo "[*] Adding new translations"
|
DIFF_BRANCH=master
|
||||||
git add .
|
if [[ "$BRANCH_EXISTS" == "true" ]]; then
|
||||||
echo "=====Translations Changed====="
|
DIFF_BRANCH=$BRANCH_NAME
|
||||||
git status
|
fi
|
||||||
echo "=============================="
|
|
||||||
echo "[*] Committing"
|
|
||||||
git commit -m "Autosync Crowdin translations"
|
|
||||||
|
|
||||||
echo "[*] Pushing"
|
DIFF_LEN=$(git diff origin/${DIFF_BRANCH} | wc -l | xargs)
|
||||||
if [ "$BRANCH_EXISTS" == "false" ]; then
|
echo "[*] git diff lines: ${DIFF_LEN}"
|
||||||
git push -u origin $BRANCH_NAME
|
echo "::set-output name=num::$DIFF_LEN"
|
||||||
|
|
||||||
|
- name: Commit changes
|
||||||
|
env:
|
||||||
|
BRANCH_NAME: ${{ steps.branch.outputs.branch-name }}
|
||||||
|
BRANCH_EXISTS: ${{ steps.branch.outputs.branch-exists }}
|
||||||
|
DIFF_BRANCH: master
|
||||||
|
DIFF_LEN: ${{ steps.files-changed.outputs.num }}
|
||||||
|
run: |
|
||||||
|
echo "=====Translations Changed====="
|
||||||
|
git diff --name-only origin/${DIFF_BRANCH}
|
||||||
|
echo "=============================="
|
||||||
|
|
||||||
|
if [ "$DIFF_LEN" != "0" ]; then
|
||||||
|
echo "[*] Adding new translations"
|
||||||
|
git add .
|
||||||
|
echo "[*] Committing"
|
||||||
|
git commit -m "Autosync Crowdin translations"
|
||||||
|
echo "[*] Pushing"
|
||||||
|
if [ "$BRANCH_EXISTS" == "false" ]; then
|
||||||
|
git push -u origin $BRANCH_NAME
|
||||||
|
else
|
||||||
|
git push
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
git push
|
echo "[*] No new docs"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Create/Update PR
|
- name: Create/Update PR
|
||||||
|
if: ${{ steps.files-changed.outputs.num }} != 0
|
||||||
env:
|
env:
|
||||||
BRANCH_NAME: ${{ steps.branch.outputs.branch-name }}
|
BRANCH_NAME: ${{ steps.branch.outputs.branch-name }}
|
||||||
BRANCH_EXISTS: ${{ steps.branch.outputs.branch-exists }}
|
BRANCH_EXISTS: ${{ steps.branch.outputs.branch-exists }}
|
||||||
@ -159,4 +183,4 @@ jobs:
|
|||||||
--body "Autosync the updated translations"
|
--body "Autosync the updated translations"
|
||||||
else
|
else
|
||||||
echo "[*] Existing PR updated"
|
echo "[*] Existing PR updated"
|
||||||
fi
|
|
||||||
|
Loading…
Reference in New Issue
Block a user