Menu

πŸ”’ GitHub : obliger le squash des pull requests vers develop
πŸ“°

πŸ”’ GitHub : obliger le squash des pull requests vers develop

DEV Community: cicdΒ·Amir DhaouadiΒ·about 12 hours ago
#kZdi7Qo8
#devtocicd#devto#dev#squash#merge
Reading 0:00
15s threshold

Context

On GitLab, a CI job can block an unsquashed MR by reading CI_MERGE_REQUEST_SQUASH_ON_MERGE .

On GitHub, the same approach is not possible: there is no "squash" checkbox on the PR .

The merge method (Merge commit, Squash, Rebase) is chosen when clicking the button, after CI has run.

There are two approaches.

Option 1 β€” Ruleset: squash only on develop

Settings β†’ General β†’ Pull Requests : keep Allow squash merging and Allow merge commits enabled (the repository settings are the master switch; a ruleset can only restrict further).

Settings β†’ Rules β†’ Rulesets β†’ New branch ruleset :

Target: develop

Enable Require a pull request before merging

Allowed merge methods : Squash only

main / master : no restriction (or a separate ruleset) to keep merge commits for release PRs.

βœ… No code, no effort for developers; applies to both the UI and the API.

⚠️ Some users report that the rule is not always enforced when the repository allows several methods.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.