From 0c17a859e29065fdd5518bd85c14787ff9b229da Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sun, 5 Jul 2026 23:08:14 +0200 Subject: [PATCH] Prevent format pushes after PR branch deletion --- action.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index b06ee6c..3b3ceee 100644 --- a/action.yml +++ b/action.yml @@ -355,6 +355,8 @@ runs: env: GITHUB_USERNAME: ${{ inputs.github_username }} GITHUB_EMAIL: ${{ inputs.github_email }} + PR_HEAD_REF: ${{ github.event.pull_request.head.ref }} + PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} run: | echo "::group::Commit and Push Changes" COMMIT_MSG="Auto-format by https://ultralytics.com/actions" @@ -364,7 +366,7 @@ runs: git reset HEAD -- .github/workflows/ # workflow changes are not permitted with default token if ! git diff --staged --quiet; then git commit -m "$COMMIT_MSG" - git push + git push --force-with-lease="refs/heads/${PR_HEAD_REF}:${PR_HEAD_SHA}" origin "HEAD:refs/heads/${PR_HEAD_REF}" else echo "No changes to commit" fi