helpers icon indicating copy to clipboard operation
helpers copied to clipboard

Add script to synchronize GH branch protection and merge property

Open gpsaggese opened this issue 7 months ago • 4 comments

We want to create a Python script that allows us to synchronize settings from an inventory file to a GitHub repo

We have explored how to do it via GitHub App and GitHub Actions, such as

  • https://github.com/apps/settings
  • https://github.com/marketplace/actions/repo-settings-sync

We want to create something similar, but using Python scripts, similar to how we synchronize our labels

  • https://github.com/causify-ai/helpers/blob/master/dev_scripts_helpers/github/dockerized_sync_gh_issue_labels.py
  • https://github.com/causify-ai/helpers/blob/master/dev_scripts_helpers/github/sync_gh_issue_labels.py

We can use either of the following clients. Feel free to evaluate which one is easier to use and meets the requirement.

  • GH CLI (https://cli.github.com/manual/)
  • PyGithub (https://github.com/PyGithub/PyGithub)

Implementation

  • Steps:
    • Create a YAML file that stores the settings
    • Create a Python script that synchronizes the settings to GitHub repo
    • Wrap that script in a dockerized executable
    • Add unit tests for important functionality
  • We can start with branch protection and merge property setting first
  • We can use the script to synchronize the labels mentioned above as sample
  • The resulting script should be placed in dev_scripts_helpers/github/

Feel free to do it in phases in multiple PRs

FYI @gpsaggese @Shaunak01 @sonniki

gpsaggese avatar May 07 '25 13:05 gpsaggese

Assigning to @sandeepthalapanane as he has been working on the scripts to synchronize the GH issue labels

Feel free to post your plan or clarification questions here

heanhsok avatar May 08 '25 17:05 heanhsok

We should also:

  • have some light testing using mocks. Something simple, just to make sure the script is not broken
  • add some documentation on how it works and how to use it

Small steps as usual is best.

Assigned to @sandeepthalapanane on the bounty gsheet too

gpsaggese avatar May 08 '25 22:05 gpsaggese

Feel free to post your plan or clarification questions here

The initial plan is to create a script similar to dockerized_sync_gh_issue_labels.py, which will have the same arguments, including options for a dry run, backup, and a sample YAML file for settings. I will do a quick run locally and verify the implementation.

Once this script is completed, we can proceed to create the Dockerized executable. After that, the test process will be quite similar to what I have done previously, including mocking. Since PyGithub is easy to mock, we can use this library in our implementation.

sandeepthalapanane avatar May 12 '25 04:05 sandeepthalapanane

Good plan and good work overall

gpsaggese avatar May 12 '25 15:05 gpsaggese