From f7b81c8dacbfe8ea3750946efd64a7b1cd57c734 Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Sat, 6 Jul 2024 10:13:26 +0100 Subject: [PATCH] Only apply patch if it is non-empty --- .github/workflows/push-changes.yml | 32 +++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/.github/workflows/push-changes.yml b/.github/workflows/push-changes.yml index d18505e..26ee808 100644 --- a/.github/workflows/push-changes.yml +++ b/.github/workflows/push-changes.yml @@ -6,13 +6,43 @@ on: types: [completed] jobs: - import: + check-for-changes: runs-on: ubuntu-20.04 if: > github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' + outputs: + is-patch-empty: ${{ steps.check-patch.outputs.is-empty }} + + steps: + - name: Download the pull request run's artifact + uses: actions/download-artifact@v4 + with: + name: sync-translations-data + github-token: ${{ secrets.GITHUB_TOKEN }} + run-id: ${{ github.event.workflow_run.id }} + + - name: Check if the patch contains any changes + id: check-patch + run: | + if [ -s sync-translations.patch ] + then + echo "Patch is not empty" + echo "is-empty=0" >> "$GITHUB_OUTPUT" + else + echo "Patch is empty" + echo "is-empty=1" >> "$GITHUB_OUTPUT" + fi + + apply-patch: + runs-on: ubuntu-20.04 + + needs: [check-for-changes] + + if: needs.check-for-changes.outputs.is-patch-empty == 0 + permissions: contents: write