This is an automated email from the ASF dual-hosted git repository.

yong pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar-test-infra.git


The following commit(s) were added to refs/heads/master by this push:
     new fd67f6c  use GITHUB_REPOSITORY to make pulsarbot reusable (#18)
fd67f6c is described below

commit fd67f6cf264a2d57bb35091697a7bc3de9223dc8
Author: Rui Fu <[email protected]>
AuthorDate: Mon Mar 15 11:42:44 2021 +0800

    use GITHUB_REPOSITORY to make pulsarbot reusable (#18)
    
    * use GITHUB_REPOSITORY to make pulsarbot resuable
    
    * add default value to BOT_TARGET_REPOSITORY
---
 pulsarbot/entrypoint.sh | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/pulsarbot/entrypoint.sh b/pulsarbot/entrypoint.sh
index 5e83946..ee71fc4 100755
--- a/pulsarbot/entrypoint.sh
+++ b/pulsarbot/entrypoint.sh
@@ -6,6 +6,7 @@ cat ${GITHUB_EVENT_PATH}
 COMMENT_BODY=$(jq -r '.comment.body' "${GITHUB_EVENT_PATH}")
 
 BOT_COMMAND_PREFIX="/pulsarbot"
+BOT_TARGET_REPOSITORY=${GITHUB_REPOSITORY:-"apache/pulsar"}
 
 if [[ ${COMMENT_BODY} != "${BOT_COMMAND_PREFIX}"* ]]; then
     echo "Not a pulsarbot command, skipping it ..."
@@ -37,11 +38,11 @@ fi
 PR_NUM=$(jq -r '.issue.number' "${GITHUB_EVENT_PATH}")
 
 # get head sha
-curl -s -H "Accept: application/vnd.github.antiope-preview+json" 
https://api.github.com/repos/apache/pulsar/git/ref/pull/${PR_NUM}/head > 
result-headsha.txt
+curl -s -H "Accept: application/vnd.github.antiope-preview+json" 
"https://api.github.com/repos/${BOT_TARGET_REPOSITORY}/git/ref/pull/${PR_NUM}/head";
 > result-headsha.txt
 HEAD_SHA=$(jq -r '.object.sha' result-headsha.txt)
 
 # get checkrun results
-curl -s -H "Accept: application/vnd.github.antiope-preview+json" 
https://api.github.com/repos/apache/pulsar/commits/${HEAD_SHA}/check-runs > 
result-check-runs.txt
+curl -s -H "Accept: application/vnd.github.antiope-preview+json" 
"https://api.github.com/repos/${BOT_TARGET_REPOSITORY}/commits/${HEAD_SHA}/check-runs";
 > result-check-runs.txt
 
 # find the failures 
 for row in $(cat result-check-runs.txt | jq -r '.check_runs[] | select(.status 
== "completed" and (.conclusion == "failure" or .conclusion == "cancelled")) | 
@base64'); do
@@ -53,7 +54,7 @@ for row in $(cat result-check-runs.txt | jq -r '.check_runs[] 
| select(.status =
     check_suite_id=$(echo $(_jq '.check_suite.id'))
     if [[ "${CHECK_NAME}" == "_all" || "${CHECK_NAME}" == "${name}" ]]; then
         echo "rerun action ${name}, check_suite_id = ${check_suite_id}"
-        curl -H "Authorization: token ${GITHUB_TOKEN}" -H "Accept: 
application/vnd.github.antiope-preview+json" -X POST 
https://api.github.com/repos/apache/pulsar/check-suites/${check_suite_id}/rerequest
+        curl -H "Authorization: token ${GITHUB_TOKEN}" -H "Accept: 
application/vnd.github.antiope-preview+json" -X POST 
"https://api.github.com/repos/${BOT_TARGET_REPOSITORY}/check-suites/${check_suite_id}/rerequest";
     else
         echo "Expect ${CHECK_NAME} but skip action ${name}, check_suite_id = 
${check_suite_id}"
     fi

Reply via email to