From 7bbe54a74e7efe073809d58131de3484f282907e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mos=C3=A8=20Giordano?= Date: Wed, 8 May 2024 14:08:19 +0200 Subject: [PATCH] [CI] Cleanup previews only if they actually exist (#323) --- .github/workflows/docs_cleanup.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docs_cleanup.yml b/.github/workflows/docs_cleanup.yml index f00153c7..7527432c 100644 --- a/.github/workflows/docs_cleanup.yml +++ b/.github/workflows/docs_cleanup.yml @@ -20,8 +20,11 @@ jobs: ref: gh-pages - name: Delete preview and push changes run: | - git config user.name "${{github.actor}}" - git config user.email "${{github.actor_id}}+${{github.actor}}@users.noreply.github.com" - git rm -rf preview/PR${{ github.event.number }} - git commit -m 'Cleanup docs for PR #${{ github.event.number }}' - git push origin gh-pages + preview_directory=preview/PR${{ github.event.number }} + if [[ -d "${preview_directory}" ]]; then + git config user.name "${{github.actor}}" + git config user.email "${{github.actor_id}}+${{github.actor}}@users.noreply.github.com" + git rm -rf "${preview_directory}" + git commit -m 'Cleanup docs for PR #${{ github.event.number }}' + git push origin gh-pages + fi