# Linking GitHub Repos to an ADO GitHub Connector (gh artado)

The ADO interface for managing GitHub repo connections is cumbersome and permission issues are common. The `gh artado` CLI extension makes bulk additions straightforward.

## Prerequisites

- [GitHub CLI](https://cli.github.com/) (`gh`) installed
- ADO Personal Access Token (PAT) with appropriate permissions

## Install the Extension

```bash
gh extension install apdarr/gh-artado
```

No need to clone the repo — the extension installs directly via the GitHub CLI.

Source: https://github.com/apdarr/gh-artado

## Set Environment Variables

```bash
export ADO_USERNAME="your.name@example.com"
export ADO_TOKEN="<your-ado-pat>"
export ADO_PROJECT="org-name/project-name"
```

PowerShell equivalent (save as `.ps1`):

```powershell
$Env:ADO_USERNAME = 'your.name@example.com'
$Env:ADO_TOKEN    = '<your-ado-pat>'
$Env:ADO_PROJECT  = 'org-name/project-name'
```

> **Warning:** The README in the GitHub repo has outdated variable names. Use the names above.

## Find Your Connection ID

```bash
gh artado list
```

Output looks like:

```
CONNECTION ID                          CONNECTION NAME      CONNECTION TYPE    CONNECTED REPO(S)
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx  MyGitHubConnection   InstallationToken  https://github.com/org/repo-a
                                                                               https://github.com/org/repo-b
```

Copy the **Connection ID** for the connector you want to add repos to.

## Add a Single Repo

```bash
gh artado add --connection <connection-id> -r https://github.com/org/repo-name
```

## Bulk Add Repos

1. Create a file (e.g. `reposToAdd.txt`) with one repo URL or name per line:

```
https://github.com/org/repo-one
https://github.com/org/repo-two
https://github.com/org/repo-three
```

2. Run the bulk add:

```bash
gh artado add-bulk -c <connection-id> -f reposToAdd.txt
```

The output confirms which repos were added. Verify in ADO under the GitHub connector settings if needed.