Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/xds-apply-updates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.ARMERIAN_PAT }}
branch: update-xds-protobuf
base: main
author: Meri Kim <dl_armeria@linecorp.com>
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/xds-sync-apis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ jobs:
uses: ./.github/workflows/xds-apply-updates.yml
with:
target_version: ${{ needs.envoy-versions.outputs.target_version }}
secrets: inherit
29 changes: 27 additions & 2 deletions xds-api/tools/update-sha.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,27 @@ set -o pipefail
set -o nounset
set -o xtrace

# Optional: set GITHUB_TOKEN to avoid API rate limits
# e.g. GITHUB_TOKEN=ghp_xxx ./update-sha.sh v1.36.4
CURL_AUTH=()
if [[ -n "${GITHUB_TOKEN:-}" ]]; then
CURL_AUTH=(-H "Authorization: token $GITHUB_TOKEN")
fi

function github_curl() {
local HTTP_CODE BODY TMPFILE
TMPFILE=$(mktemp)
HTTP_CODE=$(curl -s -o "$TMPFILE" -w '%{http_code}' "${CURL_AUTH[@]+"${CURL_AUTH[@]}"}" "$@")
BODY=$(cat "$TMPFILE")
rm -f "$TMPFILE"
if [[ "$HTTP_CODE" -lt 200 || "$HTTP_CODE" -ge 300 ]]; then
echo "error: HTTP $HTTP_CODE from $*" >&2
echo "$BODY" >&2
return 1
fi
echo "$BODY"
}

function find_sha() {
local CONTENT=$1
local DEPENDENCY=$2
Expand All @@ -21,13 +42,17 @@ function find_date() {

function find_envoy_sha_from_tag() {
local TAG=$1
curl -s https://api.github.com/repos/envoyproxy/envoy/tags | grep "$TAG" -A 4 | grep sha | awk '{print $2}' | tr -d '"' | tr -d ","
github_curl https://api.github.com/repos/envoyproxy/envoy/tags | grep "$TAG" -A 4 | grep sha | awk '{print $2}' | tr -d '"' | tr -d ","
}

CURRENT_ENVOY_RELEASE=$(cat envoy_release)
ENVOY_VERSION=$(find_envoy_sha_from_tag "$1")
if [[ -z "$ENVOY_VERSION" ]]; then
echo "error: could not resolve SHA for tag '$1' (tag not found or API rate-limited)" >&2
exit 1
fi

CURL_OUTPUT=$(curl -s "https://raw.githubusercontent.com/envoyproxy/envoy/$ENVOY_VERSION/api/bazel/repository_locations.bzl")
CURL_OUTPUT=$(github_curl "https://raw.githubusercontent.com/envoyproxy/envoy/$ENVOY_VERSION/api/bazel/repository_locations.bzl")

GOOGLEAPIS_SHA=$(find_sha "$CURL_OUTPUT" com_google_googleapis)
GOOGLEAPIS_DATE=$(find_date "$CURL_OUTPUT" com_google_googleapis)
Expand Down
Loading