From ef6e72361fef38989c4a6f8da4e05ac0fef29d97 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Sun, 20 Aug 2023 12:29:58 -0700 Subject: [PATCH] Handle empty patches, refs #1 --- .github/workflows/stable-docs.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/stable-docs.yml b/.github/workflows/stable-docs.yml index 3d6d54a..e750b70 100644 --- a/.github/workflows/stable-docs.yml +++ b/.github/workflows/stable-docs.yml @@ -44,7 +44,14 @@ jobs: git fetch origin stable-docs:stable-docs git checkout stable-docs # !stable-docs should only be in the one commit, so apply changes from that commit - git show ${{ github.sha }} -- docs/ | git apply - - git add docs/ - git commit -m "Cherry-picked docs changes from ${{ github.sha }}" || true - git push origin stable-docs + PATCH=$(git show ${{ github.sha }} -- docs/) + # Check if patch is non-empty + if [[ -n "$PATCH" ]]; then + echo "$PATCH" | git apply - + git add docs/ + git commit -m "Cherry-picked docs changes from ${{ github.sha }}" + git push origin stable-docs + else + echo "No changes to docs/ in this commit." + exit 0 + fi