|
| 1 | +# Sync Teams |
| 2 | + |
| 3 | +This target has three sub-targets: |
| 4 | + |
| 5 | +- `install`: Ensures Python 3 is installed, sets up a virtual environment, and installs the required dependencies. |
| 6 | +- `configure`: Prompts the user to input configuration details like GitHub organization name, API client ID, client |
| 7 | + secret, and GitHub token. The responses are written to a `.env` file. |
| 8 | +- `run`: Activates the virtual environment and runs two Python scripts in succession to generate teams. |
| 9 | + |
| 10 | +## Creating Teams from Github Topics |
| 11 | + |
| 12 | +To run the script and create teams and update assets, use the following command: |
| 13 | + |
| 14 | +```shell |
| 15 | +make create-teams |
| 16 | +``` |
| 17 | + |
| 18 | +This command is a convenience utility that extracts the teams to generate from Github topics. \ |
| 19 | +It runs these commands: |
| 20 | + |
| 21 | +```bash |
| 22 | +python src/utils/github_topics_to_json_file.py |
| 23 | +python src/scripts/create_teams.py teams.json |
| 24 | +``` |
| 25 | + |
| 26 | +This command will fetch the repository names and topics from the GitHub API and generate the JSON file. And then it will |
| 27 | +create the teams and update the assets. |
| 28 | + |
| 29 | +> We recommend using something like Github Actions and Github secrets to run this script on a schedule to make sure you |
| 30 | +> are always synced. |
| 31 | +
|
| 32 | +### Using External JSON File |
| 33 | + |
| 34 | +You can also provide a JSON file containing team details using a command line argument directly. The JSON file should |
| 35 | +have the following structure: |
| 36 | + |
| 37 | +```json |
| 38 | +{ |
| 39 | + "teams": [ |
| 40 | + { |
| 41 | + "name": "Team 1", |
| 42 | + "members": [ |
| 43 | + "user1", |
| 44 | + "user2" |
| 45 | + ], |
| 46 | + "resources": [ |
| 47 | + { |
| 48 | + "type": "{resource_type}", |
| 49 | + "name": "Resource 1" |
| 50 | + }, |
| 51 | + { |
| 52 | + "type": "{resource_type}", |
| 53 | + "name": "Resource 2" |
| 54 | + } |
| 55 | + ] |
| 56 | + }, |
| 57 | + { |
| 58 | + "name": "Team 2", |
| 59 | + "members": [ |
| 60 | + "user3", |
| 61 | + "user4" |
| 62 | + ], |
| 63 | + "resources": [ |
| 64 | + { |
| 65 | + "type": "{resource_type}", |
| 66 | + "name": "Resource 3" |
| 67 | + } |
| 68 | + ] |
| 69 | + } |
| 70 | + ] |
| 71 | +} |
| 72 | +``` |
| 73 | + |
| 74 | +You can run the command like this: |
| 75 | + |
| 76 | +```shell |
| 77 | +python scripts/create_teams.py path/to/teams.json |
| 78 | +``` |
| 79 | + |
| 80 | +Replace `path/to/teams.json` with the actual path to your JSON file. |
| 81 | + |
| 82 | +### Excluding Topics |
| 83 | + |
| 84 | +You can exclude certain topics from being considered when creating teams. \ |
| 85 | +To exclude topics, you could add them in the `make configure` command or update this env var in |
| 86 | +the `.env` file: `TEAM_WILDCARD_TO_EXCLUDE`. |
| 87 | + |
| 88 | +For example, to exclude topics that contain the word "test", you can set the variable as follows: |
| 89 | + |
| 90 | + TEAM_WILDCARD_TO_EXCLUDE=*test* |
| 91 | + |
| 92 | +This will exclude topics with names like "test", "test123", and "abc-testing". |
0 commit comments