diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml index 7096339ab54..216aa248713 100644 --- a/.github/workflows/automerge.yml +++ b/.github/workflows/automerge.yml @@ -26,14 +26,16 @@ jobs: git add package.json git -c user.name="GitHub" -c user.email="noreply@github.com" commit --author="github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>" -m"Fix package.json" | sed -n 1p || true git push - if [[ $(git status --porcelain | tee /dev/stderr | head -c1 | wc -c) -ne 0 || $(git clean -dffx | tee /dev/stderr | head -c1 | wc -c) -ne 0 ]]; then - exit 1 + if [[ $(git diff --stat "$(git log -1 --skip=2 --format=%H)" "$(git log -1 --format=%H)") -eq 0 ]]; then + echo "automerge_pull_action=close" >> "$GITHUB_ENV" + exit 0 fi + echo "automerge_pull_action=merge" >> "$GITHUB_ENV" fi automerge: runs-on: ubuntu-latest needs: package_json - if: ${{ github.actor == 'dependabot[bot]' && needs.package_json.result == 'success' }} + if: ${{ needs.package_json.result == 'success' && github.actor == 'dependabot[bot]' && env.automerge_pull_action == 'merge' }} steps: - name: automerge uses: actions/github-script@v6.4.1 @@ -48,10 +50,9 @@ jobs: close: runs-on: ubuntu-latest needs: package_json - if: ${{ github.actor == 'renovate[bot]' && needs.package_json.result == 'success' }} + if: ${{ needs.package_json.result == 'success' && (github.actor == 'renovate[bot]' || (github.actor == 'dependabot[bot]' && env.automerge_pull_action == 'close')) }} steps: - name: Close Pull uses: peter-evans/close-pull@v3.0.1 - continue-on-error: true with: delete-branch: true