action-commit-push icon indicating copy to clipboard operation
action-commit-push copied to clipboard

Allow forch push without lease

Open lawvs opened this issue 2 years ago • 0 comments

:memo: Brief description

By default, the force parameter is not a true --force but --force-with-lease. It will cause a push to fail when attempting to overwrite a remote branch.

This situation is likely to occur when used together with action-pull-request.

[INFO] Force pushing changes
To https://github.com/toeverything/xxx
 ! [rejected]        bot/sync -> bot/sync (stale info)
error: failed to push some refs to 'https://github.com/toeverything/xxx'
      - uses: devops-infra/action-commit-push@master
        with:
          github_token: "${{ secrets.GITHUB_TOKEN }}"
          commit_prefix: "[AUTO]"
          commit_message: "Sync"
          force: true
          target_branch: bot/sync

      - uses: devops-infra/[email protected]
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          title: "[AUTO] Update"
          target_branch: main

--force-with-lease alone, without specifying the details, will protect all remote refs that are going to be updated by requiring their current value to be the same as the remote-tracking branch we have for them. https://git-scm.com/docs/git-push#:~:text=is%20still%20valid.-,%2D%2Dforce%2Dwith%2Dlease,-alone%2C%20without%20specifying

:warning: Checklist

  • [x] Provided a clear and concise description of what the issue is.
  • [x] Given a clear and concise description of what is expected.
  • [ ] Proposed a clear and concise description of any alternative solutions or other features.
  • [x] Added any other context or screenshots about the feature request.
  • [ ] Associated pull request has been already created and link was provided.

Check CONTRIBUTING.md and CODE_OF_CONDUCT.md for more information

lawvs avatar Jun 19 '23 07:06 lawvs