From aff9542964b9412623ce1a568b77202f476a1c15 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Mon, 23 Dec 2024 21:25:51 -0700 Subject: [PATCH] end gracefully if there are no changes --- .github/workflows/maintenance.yml | 14 ++++++++++++++ .github/workflows/squash_branches.yml | 12 ++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/.github/workflows/maintenance.yml b/.github/workflows/maintenance.yml index 35de6fae0a..83aa50468e 100644 --- a/.github/workflows/maintenance.yml +++ b/.github/workflows/maintenance.yml @@ -144,8 +144,22 @@ jobs: - uses: actions/checkout@v4 with: ref: ${{ github.ref }} + fetch-depth: 0 + + - name: Check for differences + id: check-diff + run: | + git fetch origin main + if git diff --quiet origin/main ${{ needs.create-branch-prefix.outputs.base-branch }}; then + echo "No differences found between branches" + echo "has_changes=false" >> $GITHUB_OUTPUT + else + echo "Changes detected" + echo "has_changes=true" >> $GITHUB_OUTPUT + fi - name: Create Pull Request + if: steps.check-diff.outputs.has_changes == 'true' env: GH_TOKEN: ${{ secrets.LASTMJS_GITHUB_TOKEN }} run: | diff --git a/.github/workflows/squash_branches.yml b/.github/workflows/squash_branches.yml index 41c6ffa009..c3c6c5c505 100644 --- a/.github/workflows/squash_branches.yml +++ b/.github/workflows/squash_branches.yml @@ -74,10 +74,14 @@ jobs: git merge --squash $branch done - # Create a merge commit with a descriptive message - git commit -am "${{ inputs.commit-message }}" - - git push origin HEAD:$CURRENT_BRANCH + # Check if there are any changes to commit + if git diff --staged --quiet; then + echo "No changes to commit" + else + # Create a merge commit with a descriptive message + git commit -am "${{ inputs.commit-message }}" + git push origin HEAD:$CURRENT_BRANCH + fi - name: Delete branches run: |