Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🛠 Tooling: Find a cleaner approach to temporarily disabling branch protections #145

Closed
3 tasks done
JoshuaKGoldberg opened this issue Dec 23, 2022 · 5 comments · Fixed by #927
Closed
3 tasks done
Assignees
Labels
area: tooling Managing the repository's maintenance status: accepting prs Please, send a pull request to resolve this!

Comments

@JoshuaKGoldberg
Copy link
Owner

JoshuaKGoldberg commented Dec 23, 2022

Bug Report Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have pulled the latest main branch of the repository.
  • I have searched for related issues and found none that matched my issue.

Overview

#144 added scripts to the release workflow that:

  1. Before running release-it, delete any branch protections on main
  2. Afterwards, manually create branch protections on main

The branch protections are roughly a copy & paste of the script/setup.js settings. It would be nice to use some automation that can remember the existing branch protections without having to copy & paste in source code.

Additional Info

I'd tried https://github.com/benjefferies/branch-protection-bot but looks like it's not as comprehensive (benjefferies/branch-protection-bot#30). That general idea would be nice though.

@JoshuaKGoldberg JoshuaKGoldberg added area: tooling Managing the repository's maintenance status: accepting prs Please, send a pull request to resolve this! labels Dec 23, 2022
@RebeccaStevens
Copy link
Contributor

RebeccaStevens commented Feb 26, 2023

Apparently with an admin PAT token, you can push by-passing branch protection rules.
Note: You need to set persist-credentials: false for actions/checkout@v3.

There's also this action that can help with thing: https://github.com/CasperWA/push-protected (a PAT token is still required).

It's also worth noting that GitHub Apps can be given permission to by-pass branch protection rules, but this isn't currently possible with actions.

More info here: https://github.com/orgs/community/discussions/13836

@jsjoeio
Copy link
Contributor

jsjoeio commented Mar 22, 2023

Would like this as well! I thought it was very weird to see it disabled then re-enabled 😅

@JoshuaKGoldberg
Copy link
Owner Author

JoshuaKGoldberg commented Mar 22, 2023

We should note that Changesets might make this unnecessary (#297). @Andarist and I were going to look roughly this week! I'm very hopeful.

Edit: no, I ended up opting to stick with release-it for simplicity.

@JoshuaKGoldberg JoshuaKGoldberg added this to the Post-Rename Migration milestone Sep 7, 2023
JoshuaKGoldberg added a commit that referenced this issue Sep 22, 2023
## PR Checklist

- [x] Addresses an existing open issue: fixes #862
- [x] That issue was marked as [`status: accepting
prs`](https://github.com/JoshuaKGoldberg/create-typescript-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22)
- [x] Steps in
[CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/create-typescript-app/blob/main/.github/CONTRIBUTING.md)
were taken

## Overview

Switches `actions/checkout@4` to fetch from `ref: main` (the branch)
instead of the commit that triggered the workflow. Doing so should mean
that every release workflow runs on the latest commit as of when it
_starts_.

This should mean that if N release-worthy commits occur quickly:

1. The first one should always finish releasing nicely
2. The remaining 1...N commits will each 

I don't love that this solution results in 1...N release workflows each
deleting branch protection, doing nothing, then recreating the branch
protection. But given
https://github.com/orgs/community/discussions/12835 I don't see a way
around it. The branch protection shenanigans should be made better by
#145.
@JoshuaKGoldberg JoshuaKGoldberg self-assigned this Sep 22, 2023
@JoshuaKGoldberg
Copy link
Owner Author

I ended up sticking with the delete-and-recreate strategy in https://github.com/JoshuaKGoldberg/release-it-action -> #927 😞. If there's a cleaner approach I'd be very open to an issue in release-it-action.

Looking at the alternatives mentioned so far:

I might be totally off-base here 😄 so again please do file an issue if you've got a suggestion for a better way!

JoshuaKGoldberg added a commit that referenced this issue Oct 2, 2023
## PR Checklist

- [x] Addresses an existing open issue: fixes #145
- [x] That issue was marked as [`status: accepting
prs`](https://github.com/JoshuaKGoldberg/create-typescript-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22)
- [x] Steps in
[CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/create-typescript-app/blob/main/.github/CONTRIBUTING.md)
were taken

## Overview

Uses my new https://github.com/JoshuaKGoldberg/release-it-action that
contains much of the same logic as the previous `release.yml` contents.
I stuck with the "delete and recreate branch protections" approach
because (a) it's worked well and (b) other approaches had other
limitations.

I can't be 100% sure this works in this repo until it lands on `main`
and tries a few release flows. But I did test it in a separate repo and
it worked well there.
@github-actions
Copy link

github-actions bot commented Oct 2, 2023

🎉 This is included in version v1.32.0 🎉

The release is available on:

Cheers! 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: tooling Managing the repository's maintenance status: accepting prs Please, send a pull request to resolve this!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants