You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozone.apache.org by vi...@apache.org on 2020/07/14 18:56:10 UTC

[hadoop-ozone] branch master updated: HDDS-3060. /retest github comment does not work (#1137)

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

vivekratnavel pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hadoop-ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 8573e5b  HDDS-3060. /retest github comment does not work (#1137)
8573e5b is described below

commit 8573e5b72b5aec9097f485f3f680043f6ffe0b53
Author: Doroszlai, Attila <64...@users.noreply.github.com>
AuthorDate: Tue Jul 14 20:56:01 2020 +0200

    HDDS-3060. /retest github comment does not work (#1137)
---
 .github/comment-commands/retest.sh | 66 +++++++++++++++++++++++++++++++-------
 1 file changed, 54 insertions(+), 12 deletions(-)

diff --git a/.github/comment-commands/retest.sh b/.github/comment-commands/retest.sh
index b9e0632..2214264 100755
--- a/.github/comment-commands/retest.sh
+++ b/.github/comment-commands/retest.sh
@@ -14,20 +14,62 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-#doc: add new empty commit to trigger new CI build
-set +x #GITHUB_TOKEN
+#doc: provide help on how to trigger new CI build
 
-PR_URL=$(jq -r '.issue.pull_request.url' "$GITHUB_EVENT_PATH")
-read -r REPO_URL BRANCH <<<"$(curl "$PR_URL" | jq -r '.head.repo.clone_url + " " + .head.ref' | sed "s/github.com/$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/g")"
+# posting a new commit from this script does not trigger CI checks
+# https://help.github.com/en/actions/reference/events-that-trigger-workflows#triggering-new-workflows-using-a-personal-access-token
 
-git fetch "$REPO_URL" "$BRANCH"
-git checkout FETCH_HEAD
+set -eu
+
+code='```'
+
+pr_url="$(jq -r '.issue.pull_request.url' "${GITHUB_EVENT_PATH}")"
+commenter="$(jq -r '.comment.user.login' "${GITHUB_EVENT_PATH}")"
+assoc="$(jq -r '.comment.author_association' "${GITHUB_EVENT_PATH}")"
 
-export GIT_COMMITTER_EMAIL="noreply@github.com"
-export GIT_COMMITTER_NAME="GitHub actions"
+curl -LSs "${pr_url}" -o pull.tmp
+source_repo="$(jq -r '.head.repo.ssh_url' pull.tmp)"
+branch="$(jq -r '.head.ref' pull.tmp)"
+pr_owner="$(jq -r '.head.user.login' pull.tmp)"
+maintainer_can_modify="$(jq -r '.maintainer_can_modify' pull.tmp)"
 
-export GIT_AUTHOR_EMAIL="noreply@github.com"
-export GIT_AUTHOR_NAME="GitHub actions"
+# PR owner
+# =>
+# has local branch, can simply push
+if [[ "${commenter}" == "${pr_owner}" ]]; then
+  cat <<-EOF
+To re-run CI checks, please follow these steps with the source branch checked out:
+${code}
+git commit --allow-empty -m 'trigger new CI check'
+git push
+${code}
+EOF
+
+# member AND modification allowed by PR author
+# OR
+# repo owner
+# =>
+# include steps to fetch branch
+elif [[ "${maintainer_can_modify}" == "true" ]] && [[ "${assoc}" == "MEMBER" ]] || [[ "${assoc}" == "OWNER" ]]; then
+  cat <<-EOF
+To re-run CI checks, please follow these steps:
+${code}
+git fetch "${source_repo}" "${branch}"
+git checkout FETCH_HEAD
+git commit --allow-empty -m 'trigger new CI check'
+git push "${source_repo}" HEAD:"${branch}"
+${code}
+EOF
 
-git commit --allow-empty -m "empty commit to retest build" > /dev/null
-git push $REPO_URL HEAD:$BRANCH
+# other folks
+# =>
+# ping author
+else
+  cat <<-EOF
+@${pr_owner} please trigger new CI check by following these steps:
+${code}
+git commit --allow-empty -m 'trigger new CI check'
+git push
+${code}
+EOF
+fi


---------------------------------------------------------------------
To unsubscribe, e-mail: ozone-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: ozone-commits-help@hadoop.apache.org