From 6413eeeb36a7d669c2303a4fcaeafb57624c5e9b Mon Sep 17 00:00:00 2001 From: Rafael Dantas Justo Date: Wed, 11 Feb 2026 21:32:07 -0300 Subject: [PATCH] Feature: Lightweight comment New option to add a small comment to the task only with minimal information. This should help linking pull requests with Teamwork.com tasks without polluting task's discussions. --- README.md | 2 +- action.yml | 5 +++++ src/main.sh | 1 + src/teamwork.sh | 34 +++++++++++++++++++++++++--------- 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 3c54c77b..847bb6a1 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ jobs: ``` ## Usage -When creating a new PR, write in the description of the PR the URL of the task. The action will automatically add a comment in the task. +When creating a new PR, write in the description of the PR the URL of the task. The action will automatically add a comment in the task. Optionally, you may choose for a lightweight comment that will only include the PR URL and the user that performed the action, to enable this option set the `LIGHTWEIGHT_COMMENT` input to `true`. Please note, the comment will be created in Teamwork under the account you have attached to this action. If the API key of the user you are using does not have permissions to access certain projects, the comment will not be created. diff --git a/action.yml b/action.yml index f704b08a..82cb7eb4 100644 --- a/action.yml +++ b/action.yml @@ -28,6 +28,10 @@ inputs: description: 'The case-sensitive column name of the column you would like the task to be moved to if the PR was closed without being merged' required: false default: '' + LIGHTWEIGHT_COMMENT: + description: 'Generate tiny comments with minimal information' + required: false + default: 'false' runs: using: 'docker' image: 'Dockerfile' @@ -39,3 +43,4 @@ runs: - ${{ inputs.BOARD_COLUMN_OPENED }} - ${{ inputs.BOARD_COLUMN_MERGED }} - ${{ inputs.BOARD_COLUMN_CLOSED }} + - ${{ inputs.LIGHTWEIGHT_COMMENT }} \ No newline at end of file diff --git a/src/main.sh b/src/main.sh index cf553262..9646920d 100644 --- a/src/main.sh +++ b/src/main.sh @@ -20,6 +20,7 @@ main() { export BOARD_COLUMN_OPENED="$5" export BOARD_COLUMN_MERGED="$6" export BOARD_COLUMN_CLOSED="$7" + export LIGHTWEIGHT_COMMENT="$8" env::set_environment diff --git a/src/teamwork.sh b/src/teamwork.sh index b3c5e687..05433481 100644 --- a/src/teamwork.sh +++ b/src/teamwork.sh @@ -145,7 +145,10 @@ teamwork::pull_request_opened() { local -r pr_body=$(github::get_pr_body) IFS=" " read -r -a pr_stats_array <<< "$pr_stats" - teamwork::add_comment " + if [ "$LIGHTWEIGHT_COMMENT" == "true" ]; then + teamwork::add_comment "[PR]($pr_url) opened by $user" + else + teamwork::add_comment " **$user** opened a PR: **$pr_title** [$pr_url]($pr_url) \`$base_ref\` ⬅️ \`$head_ref\` @@ -158,7 +161,8 @@ ${pr_body} 🔢 ${pr_stats_array[0]} commits / 📝 ${pr_stats_array[1]} files updated / ➕ ${pr_stats_array[2]} additions / ➖ ${pr_stats_array[3]} deletions - " +" + fi teamwork::add_tag "PR Open" teamwork::move_task_to_column "$BOARD_COLUMN_OPENED" @@ -171,19 +175,27 @@ teamwork::pull_request_closed() { local -r pr_merged=$(github::get_pr_merged) if [ "$pr_merged" == "true" ]; then - teamwork::add_comment " + if [ "$LIGHTWEIGHT_COMMENT" == "true" ]; then + teamwork::add_comment "[PR]($pr_url) merged by $user" + else + teamwork::add_comment " **$user** merged a PR: **$pr_title** [$pr_url]($pr_url) " - teamwork::add_tag "PR Merged" - teamwork::remove_tag "PR Open" - teamwork::remove_tag "PR Approved" - teamwork::move_task_to_column "$BOARD_COLUMN_MERGED" + fi + teamwork::add_tag "PR Merged" + teamwork::remove_tag "PR Open" + teamwork::remove_tag "PR Approved" + teamwork::move_task_to_column "$BOARD_COLUMN_MERGED" else - teamwork::add_comment " + if [ "$LIGHTWEIGHT_COMMENT" == "true" ]; then + teamwork::add_comment "[PR]($pr_url) closed without merging by $user" + else + teamwork::add_comment " **$user** closed a PR without merging: **$pr_title** [$pr_url]($pr_url) " + fi teamwork::remove_tag "PR Open" teamwork::remove_tag "PR Approved" teamwork::move_task_to_column "$BOARD_COLUMN_CLOSED" @@ -199,7 +211,10 @@ teamwork::pull_request_review_submitted() { # Only add a message if the PR has been approved if [ "$review_state" == "approved" ]; then - teamwork::add_comment " + if [ "$LIGHTWEIGHT_COMMENT" == "true" ]; then + teamwork::add_comment "[PR]($pr_url) approved by $user" + else + teamwork::add_comment " **$user** submitted a review to the PR: **$pr_title** [$pr_url]($pr_url) @@ -208,6 +223,7 @@ teamwork::pull_request_review_submitted() { Review: **$review_state** $comment " + fi teamwork::add_tag "PR Approved" fi }