From 617074eb09ab28e2a101839d25fa1f40c97112cd Mon Sep 17 00:00:00 2001 From: Joseph Flinn Date: Fri, 13 Aug 2021 10:51:13 -0700 Subject: [PATCH] adding logic to handle if there are no changes --- .github/workflows/crowdin-sync.yml | 46 ++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/.github/workflows/crowdin-sync.yml b/.github/workflows/crowdin-sync.yml index 436aab4b842..c645bdc6666 100644 --- a/.github/workflows/crowdin-sync.yml +++ b/.github/workflows/crowdin-sync.yml @@ -130,27 +130,49 @@ jobs: unzip -o $SAVE_FILE rm $SAVE_FILE - - name: Commit changes + - name: Check changes + id: files-changed env: BRANCH_NAME: ${{ steps.branch.outputs.branch-name }} BRANCH_EXISTS: ${{ steps.branch.outputs.branch-exists }} run: | - echo "[*] Adding new translations" - git add . - echo "=====Translations Changed=====" - git status - echo "==============================" - echo "[*] Committing" - git commit -m "Autosync Crowdin translations" + DIFF_BRANCH=master + if [[ "$BRANCH_EXISTS" == "true" ]]; then + DIFF_BRANCH=$BRANCH_NAME + fi - echo "[*] Pushing" - if [ "$BRANCH_EXISTS" == "false" ]; then - git push -u origin $BRANCH_NAME + DIFF_LEN=$(git diff origin/${DIFF_BRANCH} | wc -l | xargs) + echo "[*] git diff lines: ${DIFF_LEN}" + 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 - git push + echo "[*] No new docs" fi - name: Create/Update PR + if: ${{ steps.files-changed.outputs.num }} != 0 env: BRANCH_NAME: ${{ steps.branch.outputs.branch-name }} BRANCH_EXISTS: ${{ steps.branch.outputs.branch-exists }}