From 0c3f06b6534438bc811426f3ff8cb3eb7f8dad87 Mon Sep 17 00:00:00 2001 From: Jens-Uwe Mager Date: Thu, 29 Feb 2024 15:29:58 -0500 Subject: [PATCH 1/3] Use env variables to form github urls. --- send.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/send.sh b/send.sh index 22e1bf5..6a5864c 100644 --- a/send.sh +++ b/send.sh @@ -35,7 +35,7 @@ AUTHOR_NAME="$(git log -1 "$GITHUB_SHA" --pretty="%aN")" COMMITTER_NAME="$(git log -1 "$GITHUB_SHA" --pretty="%cN")" COMMIT_SUBJECT="$(git log -1 "$GITHUB_SHA" --pretty="%s")" COMMIT_MESSAGE="$(git log -1 "$GITHUB_SHA" --pretty="%b")" | sed -E ':a;N;$!ba;s/\r{0,1}\n/\\n/g' -COMMIT_URL="https://github.com/$GITHUB_REPOSITORY/commit/$GITHUB_SHA" +COMMIT_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/commit/$GITHUB_SHA" # If, for example, $GITHUB_REF = refs/heads/feature/example-branch # Then this sed command returns: feature/example-branch @@ -59,7 +59,7 @@ if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then BRANCH_NAME="#${PR_NUM}" # Call to GitHub API to get PR title - PULL_REQUEST_ENDPOINT="https://api.github.com/repos/$GITHUB_REPOSITORY/pulls/$PR_NUM" + PULL_REQUEST_ENDPOINT="$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/pulls/$PR_NUM" WORK_DIR=$(dirname ${BASH_SOURCE[0]}) PULL_REQUEST_TITLE=$(ruby $WORK_DIR/get_pull_request_title.rb $PULL_REQUEST_ENDPOINT) From 8a1edaa1905703e9fc621bbd4e70dc1801d11cc4 Mon Sep 17 00:00:00 2001 From: Jens-Uwe Mager Date: Thu, 29 Feb 2024 15:55:17 -0500 Subject: [PATCH 2/3] Forgot one URL prefix. --- send.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/send.sh b/send.sh index 6a5864c..74d9c4c 100644 --- a/send.sh +++ b/send.sh @@ -40,7 +40,7 @@ COMMIT_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/commit/$GITHUB_SHA" # If, for example, $GITHUB_REF = refs/heads/feature/example-branch # Then this sed command returns: feature/example-branch BRANCH_NAME="$(echo $GITHUB_REF | sed 's/^[^/]*\/[^/]*\///g')" -REPO_URL="https://github.com/$GITHUB_REPOSITORY" +REPO_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" BRANCH_OR_PR="Branch" BRANCH_OR_PR_URL="$REPO_URL/tree/$BRANCH_NAME" ACTION_URL="$COMMIT_URL/checks" From 1343b61d20f3924b0083aeb21847c6ed2fe023e7 Mon Sep 17 00:00:00 2001 From: Jens-Uwe Mager Date: Thu, 29 Feb 2024 16:22:16 -0500 Subject: [PATCH 3/3] Gitea has a different way to reference branches. --- send.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/send.sh b/send.sh index 74d9c4c..8d0ba35 100644 --- a/send.sh +++ b/send.sh @@ -42,7 +42,12 @@ COMMIT_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/commit/$GITHUB_SHA" BRANCH_NAME="$(echo $GITHUB_REF | sed 's/^[^/]*\/[^/]*\///g')" REPO_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" BRANCH_OR_PR="Branch" -BRANCH_OR_PR_URL="$REPO_URL/tree/$BRANCH_NAME" +if test X$GITEA_ACTIONS = Xtrue +then + BRANCH_OR_PR_URL="$REPO_URL/src/branch/$BRANCH_NAME" +else + BRANCH_OR_PR_URL="$REPO_URL/tree/$BRANCH_NAME" +fi ACTION_URL="$COMMIT_URL/checks" COMMIT_OR_PR_URL=$COMMIT_URL if [ "$AUTHOR_NAME" == "$COMMITTER_NAME" ]; then