Skip settings sync for repos that are already archived#988
Open
pcrumley wants to merge 1 commit into
Open
Conversation
When a repository is archived, GitHub treats it as read-only and rejects any settings update (repository, branch protection, labels, teams, etc.) with a 403 "Repository was archived so is read-only." error. `updateRepos` only used the archive plugin's state to decide whether to archive/unarchive a repo, but it still ran the repository plugin and all child plugins unconditionally. For repos that are already archived and are staying archived, this issues a `repos.update()` (and other writes) against a read-only repo every sync, which 403s, gets logged as an error and surfaces as a failing check run. Skip the repository and child plugins when a repo is archived and is not being unarchived in this run. Newly-archived repos (shouldArchive) are still configured first and archived last, and repos being unarchived are configured after the unarchive, so those paths are unchanged. Add regression tests covering already-archived, newly-archived and non-archived repos.
Author
|
The issue this is trying to fix is that if you have set a repo to be archived then someone changes some of the settings manually by click-opsing them, the safe-settings bot will try to patch those settings back to the settings in the repo. However it is unable to do that because github api 403's whenever you make a request to change a setting of a archived repo. I can provide a minimal example if you would like. I also am not sure if this is the best way to solve the problem. The other solution would be to unarchive the repo, set all the settings back to what was in the config, then re-archive the repo. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
My deployment of github safe-settings fails at the sync step on archived repos, becase GitHub treats archived repos as read-only and rejects any settings update (repository, branch protection, labels, teams, etc.) with a 403 "Repository was archived so is read-only." error.
updateReposonly used the archive plugin's state to decide whether to archive/unarchive a repo, but it still ran the repository plugin and all child plugins unconditionally. For repos that are already archived and are staying archived, this issues arepos.update()(and other writes) against a read-only repo every sync, which 403s, gets logged as an error and surfaces as a failing check run.Skip the repository and child plugins when a repo is archived and is not being unarchived in this run. Newly-archived repos (shouldArchive) are still configured first and archived last, and repos being unarchived are configured after the unarchive, so those paths are unchanged.
Add regression tests covering already-archived, newly-archived and non-archived repos.