|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# This script lists URLs changed by the target PR. You can jump to target page quickly by clicking those. |
| 4 | +# Syntax: get-changed-urls.sh <PR number> [<page top URL>] |
| 5 | +# Example: |
| 6 | +# $ get-changed-urls.sh 28542 |
| 7 | +# http://localhost:1313/ja/docs/concepts/configuration/manage-resources-containers |
| 8 | +# http://localhost:1313/ja/docs/concepts/policy/limit-range |
| 9 | +# http://localhost:1313/ja/docs/concepts/policy/resource-quotas |
| 10 | +# http://localhost:1313/ja/docs/reference/command-line-tools-reference/feature-gates |
| 11 | +# http://localhost:1313/ja/docs/setup/best-practices/cluster-large |
| 12 | +# |
| 13 | +# If no <page top URL> is passed, it will assume "http://localhost:1313". |
| 14 | +# It's the default endpoint for "make container-serve" or "make serve". |
| 15 | +# Please look at the README(https://github.com/kubernetes/website#using-this-repository) to serve endpoint. |
| 16 | +# Or you can pass any strings to <page top URL>. |
| 17 | +# You can get URLs for upstream by passing <page top URL> as "https://kubernetes.io". |
| 18 | + |
| 19 | +set -e |
| 20 | + |
| 21 | +if [[ ${1} == "" ]] |
| 22 | +then |
| 23 | + echo "This script prints all URLs updated by target PR number." |
| 24 | + echo "You can jump to updated pages quickly when PR review." |
| 25 | + echo "This is intended for using with \"make container-serve\"." |
| 26 | + echo "" |
| 27 | + echo "Syntax: get-changed-urls.sh <PR number> [<page top URL>]" |
| 28 | + echo "Example: get-changed-urls.sh 12345" |
| 29 | + echo "If no <page top URL> is passed, it will assume \"http://localhost:1313\"" |
| 30 | + exit 1 |
| 31 | +fi |
| 32 | + |
| 33 | +PAGE_TOP=${2:-"http://localhost:1313"} |
| 34 | + |
| 35 | +GITHUB_REPOSITORY="kubernetes/website" |
| 36 | +PR_NUM=${1} |
| 37 | + |
| 38 | +# URL for calling GitHub API |
| 39 | +# For detail: https://docs.github.com/en/rest/reference/pulls#list-pull-requests-files |
| 40 | +GITHUB_API_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${PR_NUM}/files" |
| 41 | + |
| 42 | +# Get files included in target PR |
| 43 | +URLS=$(curl --silent -X GET ${GITHUB_API_URL} | jq -r '.[].filename' | \ |
| 44 | + sed -e "s/^content\/en//g" -e "s/^content//g" -e "s/.md$//g" | grep "docs" | xargs -I {} echo ${PAGE_TOP}{}) |
| 45 | +for u in ${URLS} |
| 46 | +do |
| 47 | + echo ${u} |
| 48 | +done |
0 commit comments