Visitar URL original
Merge pull request #90 from wp-cli/authenticate-repo-listing · wp-cli/wp-cli-dev@b49433d · GitHub
Skip to content

Commit b49433d

Browse files
authored
Merge pull request #90 from wp-cli/authenticate-repo-listing
Authenticate the repository listing on CI
2 parents 46bc3ec + c6b3dcc commit b49433d

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎.maintenance/clone-all-repositories.sh‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ elif [[ -z "${CLONE_JOBS:-}" && -z "${WPCLI_DEV_JOBS:-}" && "${CORES}" -gt "${MA
4040
fi
4141

4242
# Lists the repositories of the organization as "name<TAB>clone_url<TAB>ssh_url"
43-
# lines. Uses the GitHub CLI when it is logged in, and the GitHub API with
44-
# GH_TOKEN or GITHUB_TOKEN, or anonymously, otherwise.
43+
# lines. Uses the GitHub CLI when it is logged in, and the GitHub API
44+
# otherwise, with GH_TOKEN, GITHUB_TOKEN or Composer's GitHub token. On CI,
45+
# setup-php hands the job token to Composer, and the anonymous rate limit is
46+
# shared with every other job on the same runner address.
4547
fetch_repositories() {
4648
if command -v gh &>/dev/null && gh auth status --hostname github.com &>/dev/null; then
4749
gh api --paginate 'orgs/wp-cli/repos?per_page=100' --jq '.[] | [.name, .clone_url, .ssh_url] | @tsv'
@@ -50,6 +52,9 @@ fetch_repositories() {
5052

5153
local curl_opts=(-sS)
5254
local token="${GH_TOKEN:-${GITHUB_TOKEN:-}}"
55+
if [[ -z "${token}" ]] && command -v composer &>/dev/null; then
56+
token=$(composer config --global github-oauth.github.com 2>/dev/null || true)
57+
fi
5358
if [[ -n "${token}" ]]; then
5459
curl_opts+=(--header "Authorization: Bearer ${token}")
5560
fi

0 commit comments

Comments
 (0)