From 50898c97c0a99cc198b530c80868164734f3fd90 Mon Sep 17 00:00:00 2001 From: Satyam Soni <94950988+satyampsoni@users.noreply.github.com> Date: Mon, 10 Feb 2025 11:16:39 +0530 Subject: [PATCH 1/3] Update auto-label.yml --- .github/workflows/auto-label.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/auto-label.yml b/.github/workflows/auto-label.yml index 00b822dd7b..677d6c09b6 100644 --- a/.github/workflows/auto-label.yml +++ b/.github/workflows/auto-label.yml @@ -1,4 +1,4 @@ -name: Devtron-auto-labeller +name: Devtron-auto-labeler on: issue_comment: @@ -25,7 +25,7 @@ jobs: ISSUE_NUMBER=$(jq -r '.issue.number // .pull_request.number' "$GITHUB_EVENT_PATH") COMMENT_AUTHOR=$(jq -r '.comment.user.login' "$GITHUB_EVENT_PATH") - ORG_NAME="satyam-tests" + ORG_NAME="devtron-labs" # Check if the person is authorized to add labels curl -s -H "Authorization: token $GH_TOKEN" "https://api.github.com/orgs/$ORG_NAME/members/$COMMENT_AUTHOR" > /dev/null @@ -64,4 +64,4 @@ jobs: else echo "The label '$LABEL_NAME_TO_REMOVE' is not attached to issue #$ISSUE_NUMBER." fi - fi \ No newline at end of file + fi From 79d50fbefa34688705c5c9a6be710d62c4311806 Mon Sep 17 00:00:00 2001 From: Satyam Soni <94950988+satyampsoni@users.noreply.github.com> Date: Mon, 24 Feb 2025 17:02:29 +0530 Subject: [PATCH 2/3] Update auto-label.yml --- .github/workflows/auto-label.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-label.yml b/.github/workflows/auto-label.yml index 677d6c09b6..b5bbc98678 100644 --- a/.github/workflows/auto-label.yml +++ b/.github/workflows/auto-label.yml @@ -53,7 +53,7 @@ jobs: fi fi - # Remove Label Logic + # Removes Label Logic if [[ "$COMMENT_BODY" =~ ^/remove[[:space:]](.+)$ ]]; then LABEL_NAME_TO_REMOVE=$(echo "$COMMENT_BODY" | sed -n 's|/remove ||p') From d5c0cd5348f09300a4de590f89af73cc9c023a1f Mon Sep 17 00:00:00 2001 From: satyampsoni Date: Mon, 24 Feb 2025 17:48:07 +0530 Subject: [PATCH 3/3] outsiders can't add labels --- .github/workflows/auto-label.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/auto-label.yml b/.github/workflows/auto-label.yml index b5bbc98678..5114ad3190 100644 --- a/.github/workflows/auto-label.yml +++ b/.github/workflows/auto-label.yml @@ -28,8 +28,8 @@ jobs: ORG_NAME="devtron-labs" # Check if the person is authorized to add labels - curl -s -H "Authorization: token $GH_TOKEN" "https://api.github.com/orgs/$ORG_NAME/members/$COMMENT_AUTHOR" > /dev/null - if [[ $? -ne 0 ]]; then + RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: token $GH_TOKEN" "https://api.github.com/orgs/$ORG_NAME/members/$COMMENT_AUTHOR") + if [[ "$RESPONSE" -ne 204 ]]; then gh issue comment "$ISSUE_NUMBER" --body "Hi @$COMMENT_AUTHOR, you must be a member of the organization '$ORG_NAME' to add or remove labels." echo "User '$COMMENT_AUTHOR' is not a member of the organization '$ORG_NAME'. Exiting." exit 1