Skip to content

Commit 3fac43c

Browse files
feat: add script to retrieve organization databaseId for VNet injection (#132)
* feat: add script to retrieve organization databaseId for VNet injection * fix: update example Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix: correct example usage in get-organization-id.sh * fix: add missing header for GitHub API request in get-organization-database-id-for-vnet.sh * docs: fix script name Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * docs: update script description Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix: remove trailing spaces in GraphQL queries --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent d527b88 commit 3fac43c

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

gh-cli/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,19 @@ The list will contain the repository name, source (CODEOWNERS file), and kind of
931931

932932
Repositories with no CODEONWERS files or CODEOWNERS errors will not be listed.
933933

934+
### get-organization-database-id-for-vnet.sh
935+
936+
Retrieves the databaseId of an organization for use with VNet injection configuration.
937+
938+
Usage:
939+
940+
```shell
941+
./get-organization-database-id-for-vnet.sh <organization>
942+
```
943+
944+
> [!NOTE]
945+
> See [Configuring private networking for GitHub-hosted runners in your organization](https://docs.github.com/en/organizations/managing-organization-settings/configuring-private-networking-for-github-hosted-runners-in-your-organization#1-obtain-the-databaseid-for-your-organization) for more information on using the databaseId with VNet injection
946+
934947
### get-organization-id.sh
935948

936949
Get the organization ID used for other GraphQL calls. Use the login of the Organization as the input.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
# This script retrieves the databaseId of your organization to be used in the VNet injection scripts
4+
# https://docs.github.com/en/organizations/managing-organization-settings/configuring-private-networking-for-github-hosted-runners-in-your-organization#1-obtain-the-databaseid-for-your-organization
5+
6+
if [ -z "$1" ]; then
7+
echo "Usage: $0 <org>"
8+
echo "Example: ./get-organization-database-id-for-vnet.sh joshjohanning-org"
9+
exit 1
10+
fi
11+
12+
org="$1"
13+
14+
gh api graphql -H X-Github-Next-Global-ID:1 -f organization="$org" -f query='
15+
query ($organization: String!)
16+
{ organization(login: $organization) {
17+
login
18+
databaseId
19+
}
20+
}
21+
'

gh-cli/get-organization-id.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
if [ -z "$1" ]; then
44
echo "Usage: $0 <org>"
5-
echo "Example: ./get-enterprise-id.sh joshjohanning-org"
5+
echo "Example: ./get-organization-id.sh joshjohanning-org"
66
exit 1
77
fi
88

@@ -14,7 +14,7 @@ query ($organization: String!)
1414
{ organization(login: $organization) {
1515
login
1616
name
17-
id
17+
id
1818
}
1919
}
2020
'

0 commit comments

Comments
 (0)