Skip to content

Replace elastic/infra GitHub API check with public GCS branches endpoint#6698

Open
Copilot wants to merge 4 commits intomainfrom
copilot/update-check-if-file-exist
Open

Replace elastic/infra GitHub API check with public GCS branches endpoint#6698
Copilot wants to merge 4 commits intomainfrom
copilot/update-check-if-file-exist

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 30, 2026

The DRA pipeline was checking branch availability by querying the private elastic/infra GitHub repo via the GitHub API, requiring a GITHUB_REPO_TOKEN. This should instead use the public endpoint https://storage.googleapis.com/artifacts-api/snapshots/branches.json.

Changes

  • .buildkite/hooks/pre-command
    • Removed GITHUB_REPO_TOKEN dependency
    • Replaced check_if_file_exist_in_repo() (GitHub API + file path lookup) with check_if_branch_available() (public GCS JSON endpoint)
    • Uses jq any(. == $branch) for exact branch name matching — avoids false positives from substring matches
    • Updated call site to match new single-argument signature
# Before: queried private elastic/infra repo via GitHub API
check_if_file_exist_in_repo() {
    local path_to_file="cd/release/release-manager/project-configs/${branchName}/build.gradle"
    local response=$(curl --fail -s -H "Authorization: token $GITHUB_REPO_TOKEN" \
        https://api.github.com/repos/elastic/${repoName}/contents/${path_to_file} | ...)
}

# After: queries public GCS endpoint
check_if_branch_available() {
    local url="https://storage.googleapis.com/artifacts-api/snapshots/branches.json"
    local response=$(curl --fail -s "${url}")
    if echo "${response}" | jq -e --arg branch "${branch}" 'any(. == $branch)' > /dev/null 2>&1; then
        ...
    fi
}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://storage.googleapis.com/artifacts-api/snapshots/branches.json
    • Triggering command: /usr/bin/curl curl -s REDACTED (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Update implementation to check branch availability Replace elastic/infra GitHub API check with public GCS branches endpoint Mar 30, 2026
Copilot finished work on behalf of v1v March 30, 2026 17:43
Copilot AI requested a review from v1v March 30, 2026 17:43
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Mar 30, 2026

This pull request does not have a backport label. Could you fix it @Copilot? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-./d./d is the label to automatically backport to the 8./d branch. /d is the digit
  • backport-active-all is the label that automatically backports to all active branches.
  • backport-active-8 is the label that automatically backports to all active minor branches for the 8 major.
  • backport-active-9 is the label that automatically backports to all active minor branches for the 9 major.

local branch=${1}
local url="https://storage.googleapis.com/artifacts-api/snapshots/branches.json"
local response=$(curl --fail -s "${url}")
if echo "${response}" | jq -e --arg branch "${branch}" '.branches | any(. == $branch)' > /dev/null 2>&1; then
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image

# TODO remove and replace _branch with BUILDKITE_BRANCH after PR tests
_branch="${DRA_BRANCH:="${BUILDKITE_BRANCH:=""}"}"

check_if_file_exist_in_repo "infra" "${_branch}" #TODO should be changed to "main" for rollback...
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@v1v v1v marked this pull request as ready for review March 30, 2026 17:53
@v1v v1v requested a review from a team as a code owner March 30, 2026 17:53
@v1v
Copy link
Copy Markdown
Member

v1v commented Mar 30, 2026

buildkite test

@v1v
Copy link
Copy Markdown
Member

v1v commented Mar 31, 2026

/test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DRA pipeline step accessed the elastic/infra to know if a given branch is available

3 participants