Skip to content
Merged
Changes from all 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
14 changes: 12 additions & 2 deletions pr-comment/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ if [ -z "$head_sha" ]; then
head_sha="$GITHUB_SHA"
fi

# Capture the PR base SHA (the commit the PR is opened against). Pinning to
# the SHA gives the review page a stable base reference: if the base branch
# advances after the PR was opened, the review still shows the comparison
# against the original base. base_ref is still sent for backward compatibility
# with reports that don't yet have base_sha.
base_sha=$(jq -r '.pull_request.base.sha // empty' "$GITHUB_EVENT_PATH")

# Extract owner and repo from GITHUB_REPOSITORY
owner="${GITHUB_REPOSITORY%%/*}"
repo="${GITHUB_REPOSITORY#*/}"
Expand All @@ -67,7 +74,9 @@ urlencode() { printf '%s' "$1" | jq -sRr @uri; }
# Strip git ref prefix (e.g. "origin/main:path.yaml" -> "path.yaml", "HEAD:path.yaml" -> "path.yaml")
base_path=$(echo "$base" | sed 's/.*://')
rev_path=$(echo "$revision" | sed 's/.*://')
free_review_url="https://www.oasdiff.com/review?owner=${owner}&repo=${repo}&base_sha=${GITHUB_BASE_REF}&rev_sha=${head_sha}&base_file=$(urlencode "$base_path")&rev_file=$(urlencode "$rev_path")"
# Prefer the base SHA over the branch name so the link is commit-pinned.
free_base_sha="${base_sha:-$GITHUB_BASE_REF}"
free_review_url="https://www.oasdiff.com/review?owner=${owner}&repo=${repo}&base_sha=${free_base_sha}&rev_sha=${head_sha}&base_file=$(urlencode "$base_path")&rev_file=$(urlencode "$rev_path")"
echo "::notice::📋 View API changes → ${free_review_url}"

# Build the JSON payload
Expand All @@ -78,10 +87,11 @@ payload=$(jq -n \
--argjson pr "$pr_number" \
--arg sha "$head_sha" \
--arg base_ref "$GITHUB_BASE_REF" \
--arg base_sha "$base_sha" \
--arg base_file "$base" \
--arg rev_file "$revision" \
--argjson changes "$changes" \
'{github: {token: $token, owner: $owner, repo: $repo, pull_number: $pr, head_sha: $sha, base_ref: $base_ref}, base_file: $base_file, rev_file: $rev_file, changes: $changes}')
'{github: {token: $token, owner: $owner, repo: $repo, pull_number: $pr, head_sha: $sha, base_ref: $base_ref, base_sha: $base_sha}, base_file: $base_file, rev_file: $rev_file, changes: $changes}')

# POST to oasdiff-service (requires token)
if [ -z "$oasdiff_token" ]; then
Expand Down
Loading