Skip to content

Commit 5ec1dfa

Browse files
committed
[ros2-setup] Use GITHUB_TOKEN when available
1 parent 7d35b6f commit 5ec1dfa

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

ros2-setup/install.bash

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,19 @@ fi
4646
ros_apt_source_pkg_name="ros2-apt-source"
4747

4848
installed_version=$(dpkg -s ${ros_apt_source_pkg_name} 2>/dev/null | grep -F "Version" | awk '{print $2}')
49-
newest_version=$(curl -s https://api.github.com/repos/ros-infrastructure/ros-apt-source/releases/latest | grep -F "tag_name" | awk -F\" '{print $4}')
49+
50+
CURL_ARGS=("-H" "Accept: application/vnd.github+json")
51+
if [[ -n ${GITHUB_TOKEN} ]]
52+
then
53+
CURL_ARGS+=("-H" "Authorization: Bearer ${GITHUB_TOKEN}")
54+
fi
55+
newest_version=$(curl "${CURL_ARGS[@]}" -sL https://api.github.com/repos/ros-infrastructure/ros-apt-source/releases/latest | jq -r '.tag_name')
56+
57+
if [[ ${newest_version} == "null" ]]
58+
then
59+
tue-install-error "Failed to get the newest version of '${ros_apt_source_pkg_name}'"
60+
fi
61+
5062
needs_install=true
5163
if [[ -n ${installed_version} ]]
5264
then

0 commit comments

Comments
 (0)