Skip to content

Commit

Permalink
Avoid hardcoding repo in fetch-pr
Browse files Browse the repository at this point in the history
  • Loading branch information
jhawthorn committed Oct 9, 2024
1 parent 82ae82e commit 1e21c1d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion bin/fetch-pr
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ def pull_request_number
ENV.fetch("BUILDKITE_PULL_REQUEST") { raise "Missing BUILDKITE_PULL_REQUEST!" }
end

uri = URI("https://api.github.com/repos/rails/rails/pulls/#{pull_request_number}")
def github_repo
ENV.fetch("BUILDKITE_REPO")[%r{github\.com[/:](.+?)(?:\.git)?\z}, 1]
end

uri = URI("https://api.github.com/repos/#{github_repo}/pulls/#{pull_request_number}")

req = Net::HTTP::Get.new(uri)
req["Authorization"] = "token #{github_token}"
Expand Down
1 change: 1 addition & 0 deletions pipelines/rails-ci/initial.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ steps:
(docker run --rm \
-v "$$PWD":/app:ro -w /app \
-e GITHUB_PUBLIC_REPO_TOKEN \
-e BUILDKITE_REPO \
-e BUILDKITE_PULL_REQUEST \
ruby:latest \
.buildkite/bin/fetch-pr > .buildkite/tmp/.pr-meta.json) || true
Expand Down

0 comments on commit 1e21c1d

Please sign in to comment.