Github: stack PR workflow and prevent merging stack into one another #343
OlivierLDff
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I'm using stack PR workflow for github.
I have the assle of manually choosing the base branch in github, I don't have anything to help with that yet.
I want to share a simple action I added that fix a big pain-point in the workflow: Merging a PR into another. Often a coworker would review my stack into the wrong order, and I would see a big green ready to merge button. If not paying attention that the PR base branch isn't
main
, I could merge a PR into another branch, creating a mess, and not clean commit history inmain
.So here I present to you an action that will prevent you from merging by making the CI failing and adding a
🗄️ stacked
label to the PR automatically.Example:
![image](https://private-user-images.githubusercontent.com/17255804/314408862-de57511b-4cee-42fc-ba1d-e2dc24f41a1d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5NDk4MTUsIm5iZiI6MTczODk0OTUxNSwicGF0aCI6Ii8xNzI1NTgwNC8zMTQ0MDg4NjItZGU1NzUxMWItNGNlZS00MmZjLWJhMWQtZTJkYzI0ZjQxYTFkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA3VDE3MzE1NVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWRlYTNkYTEzN2RkNmUzNDA1NjNiNDA3MTM4YTI4ZGZjODgxNjU5ZGY1MGRlMGI1M2RlOGYxNWM5YTQ3YWNmM2EmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.eh2gMappgdsLHnuFHRHY9rMT4aQbMGmLOCgNjcy2psQ)
As you can see the label is automatically added and removed from the PR.
Then on my first PR targeting
![image](https://private-user-images.githubusercontent.com/17255804/314409151-44b9d7c5-e20b-4368-b094-60097cadd3eb.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5NDk4MTUsIm5iZiI6MTczODk0OTUxNSwicGF0aCI6Ii8xNzI1NTgwNC8zMTQ0MDkxNTEtNDRiOWQ3YzUtZTIwYi00MzY4LWIwOTQtNjAwOTdjYWRkM2ViLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA3VDE3MzE1NVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTA2ZTg3MjU0ZTRmM2Y5YzU2YjBkNWM2N2RkYTdiNDhjYmY4MGQ3MmY1ZTIwYWY4N2IxZTJlYzI4MGIyZTdmZGQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.KGz_WeMYGESna-PvZ4-7wwfIYxgVSLv1lZWv8uCPBBY)
![image](https://private-user-images.githubusercontent.com/17255804/314409224-75491bc1-a16c-4b69-ba60-c93cc846ae0a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5NDk4MTUsIm5iZiI6MTczODk0OTUxNSwicGF0aCI6Ii8xNzI1NTgwNC8zMTQ0MDkyMjQtNzU0OTFiYzEtYTE2Yy00YjY5LWJhNjAtYzkzY2M4NDZhZTBhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA3VDE3MzE1NVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWI2ZDUwZjBiNTQ2NDIxMTVmZjQ1NGE0YzMzNWFlY2YxNjIwODE4MmViMmI3Yzg5YTk0NzlkNzEyNzk1ZjY2NjYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.Mlja0JymFqB0QaiI12KfScPl5yj7jFZjfVWCstPJ_h8)
main
:And the subsequent one:
Have a nice day, I hope this action could help someone in their workflow, and whatnot if someone has improvement
EDIT:
CLI workflow
I found some nice CLI tricks to ease the workflow.
Create the PR on github based on the correct branch:
gh pr create --base $(git stack --format list --stack current | tail -n 2 | head -n 1) --fill
Force push all branchs of a stack:
git push origin $(git stack --format list --stack all) --force
Beta Was this translation helpful? Give feedback.
All reactions