From d92059b082f5ce3ffc31e16445a27ff34f9a8a55 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Wed, 18 Jun 2025 22:55:40 +0900 Subject: [PATCH] Include user-agent header in requests to crates.io Based on https://github.com/taiki-e/cache-cargo-install-action/commit/3f363be7b68439d8d6299b71308c21e694c96d08 by Joe Birr-Pixton. Fix the underlying cause of https://github.com/taiki-e/install-action/issues/1005. Co-authored-by: Joe Birr-Pixton --- action.yml | 1 + main.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index ac0b4b1b..72d6de5f 100644 --- a/action.yml +++ b/action.yml @@ -49,3 +49,4 @@ runs: INPUT_CHECKSUM: ${{ inputs.checksum }} INPUT_FALLBACK: ${{ inputs.fallback }} DEFAULT_GITHUB_TOKEN: ${{ github.token }} + ACTION_USER_AGENT: ${{ github.action_repository }} (${{ github.action_ref }}) diff --git a/main.sh b/main.sh index e5a66331..94d916ec 100755 --- a/main.sh +++ b/main.sh @@ -220,7 +220,7 @@ read_manifest() { # TODO: don't hardcode tool name and use 'immediate_yank_reflection' field in base manifest. case "${tool}" in cargo-nextest | nextest) - crate_info=$(curl --proto '=https' --tlsv1.2 -fsSL --retry 10 "https://crates.io/api/v1/crates/${rust_crate}" || true) + crate_info=$(curl -v --user-agent "${ACTION_USER_AGENT}" --proto '=https' --tlsv1.2 -fsSL --retry 10 "https://crates.io/api/v1/crates/${rust_crate}" || true) if [[ -n "${crate_info}" ]]; then while true; do yanked=$(jq -r ".versions[] | select(.num == \"${exact_version}\") | .yanked" <<<"${crate_info}")