From 6e7ee2647eb23a2d8fea5d462958564fcf6711da Mon Sep 17 00:00:00 2001 From: Brandon Oldenhof Date: Fri, 27 May 2022 15:14:21 +0200 Subject: [PATCH 01/13] Disabled notifications for comments --- src/teamwork.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/teamwork.sh b/src/teamwork.sh index dda2fe93..4f5eddd4 100644 --- a/src/teamwork.sh +++ b/src/teamwork.sh @@ -94,7 +94,7 @@ teamwork::add_comment() { response=$(curl -X "POST" "$TEAMWORK_URI/projects/api/v1/tasks/$TEAMWORK_TASK_ID/comments.json" \ -u "$TEAMWORK_API_TOKEN"':' \ -H 'Content-Type: application/json; charset=utf-8' \ - -d "{ \"comment\": { \"body\": \"${body//\"/}\", \"notify\": true, \"content-type\": \"text\", \"isprivate\": false } }" ) + -d "{ \"comment\": { \"body\": \"${body//\"/}\", \"notify\": false, \"content-type\": \"text\", \"isprivate\": false } }" ) log::message "$response" } From 6cbc597b1d64dfb0e73e83ae43adcfc9c0325769 Mon Sep 17 00:00:00 2001 From: Brandon Oldenhof Date: Wed, 8 Feb 2023 11:32:44 +0100 Subject: [PATCH 02/13] Feature: move board to "In Progress" when changes have been requested on PR. Updated actions to update task estimates when PR status changes --- .github/workflows/test.yml | 1 + README.md | 2 ++ action.yml | 13 +++++++++---- src/main.sh | 1 + src/teamwork.sh | 17 ++++++++++++++++- 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4bab5c6c..5e306b76 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,3 +20,4 @@ jobs: BOARD_COLUMN_OPENED: "PR Open" BOARD_COLUMN_MERGED: "Ready to Test" BOARD_COLUMN_CLOSED: "Rejected" + BOARD_COLUMN_FEEDBACK: "PR Open" diff --git a/README.md b/README.md index bce234fb..d16acf0b 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ jobs: BOARD_COLUMN_OPENED: 'PR Open' BOARD_COLUMN_MERGED: 'Ready to Test' BOARD_COLUMN_CLOSED: 'Rejected' + BOARD_COLUMN_FEEDBACK: 'PR Open' env: IGNORE_PROJECT_IDS: '1 2 3' @@ -75,6 +76,7 @@ You may also specify columns you'd like the task to be moved to on every stage o - `BOARD_COLUMN_OPENED`: The case-sensitive column name of the column you'd like the task to be moved to once the PR has been opened - `BOARD_COLUMN_MERGED`: The case-sensitive column name of the column you'd like the task to be moved to once the PR has been merged - `BOARD_COLUMN_CLOSED`: The case-sensitive column name of the column you'd like the task to be moved to if the PR was closed without being merged +- `BOARD_COLUMN_FEEDBACK`: The case-sensitive column name of the column you would like the task to be moved to when the PR receives feedback The column names will be checked against all board columns in the task's project, this will be using a `contains()` method so you may specify part of the name instead of the full name, however this `contains()` check is case-sensitive. The first matching column will be used. diff --git a/action.yml b/action.yml index f704b08a..c032b1db 100644 --- a/action.yml +++ b/action.yml @@ -15,19 +15,23 @@ inputs: required: true AUTOMATIC_TAGGING: description: 'Do you want to enable automatic tagging: true/false' - required: false + required: true BOARD_COLUMN_OPENED: description: 'The case-sensitive column name of the column you would like the task to be moved to once the PR has been opened' required: false - default: '' + default: 'Testing ROX' BOARD_COLUMN_MERGED: description: 'The case-sensitive column name of the column you would like the task to be moved to once the PR has been merged' required: false - default: '' + default: 'Testing klant/PO' BOARD_COLUMN_CLOSED: 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: '' + default: 'To do' + BOARD_COLUMN_FEEDBACK: + description: 'The case-sensitive column name of the column you would like the task to be moved to when the PR receives feedback' + required: false + default: 'In progress' runs: using: 'docker' image: 'Dockerfile' @@ -39,3 +43,4 @@ runs: - ${{ inputs.BOARD_COLUMN_OPENED }} - ${{ inputs.BOARD_COLUMN_MERGED }} - ${{ inputs.BOARD_COLUMN_CLOSED }} + - ${{ inputs.BOARD_COLUMN_FEEDBACK }} diff --git a/src/main.sh b/src/main.sh index cf553262..12c71918 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 BOARD_COLUMN_FEEDBACK="$8" env::set_environment diff --git a/src/teamwork.sh b/src/teamwork.sh index 4f5eddd4..56709219 100644 --- a/src/teamwork.sh +++ b/src/teamwork.sh @@ -117,6 +117,17 @@ teamwork::add_tag() { fi } +teamwork::update_estimation() { + local -r estimation=$1 + + response=$(curl -X "PUT" "$TEAMWORK_URI/projects/api/v1/tasks/$TEAMWORK_TASK_ID.json" \ + -u "$TEAMWORK_API_TOKEN"':' \ + -H 'Content-Type: application/json; charset=utf-8' \ + -d "{ \"todo-item\": { \"estimated-minutes\": \"${estimation//\"/}\" } }" ) + + log::message "$response" +} + teamwork::remove_tag() { local -r tag_name=$1 @@ -162,6 +173,7 @@ ${pr_body} teamwork::add_tag "PR Open" teamwork::move_task_to_column "$BOARD_COLUMN_OPENED" + teamwork::update_estimation 15 } teamwork::pull_request_closed() { @@ -198,7 +210,9 @@ teamwork::pull_request_review_submitted() { local -r comment=$(github::get_review_comment) # Only add a message if the PR has been approved - if [ "$review_state" == "approved" ]; then + if [ "$review_state" != "approved" ]; then + teamwork::move_task_to_column "$BOARD_COLUMN_FEEDBACK" + elif [ "$review_state" == "approved" ]; then teamwork::add_comment " **$user** submitted a review to the PR: **$pr_title** [$pr_url]($pr_url) @@ -209,6 +223,7 @@ Review: **$review_state** $comment " teamwork::add_tag "PR Approved" + teamwork::update_estimation 0 fi } From 34b63915a5fbe83e581525f68f33cf488f6da33d Mon Sep 17 00:00:00 2001 From: Brandon Oldenhof Date: Mon, 27 Feb 2023 16:44:54 +0100 Subject: [PATCH 03/13] Fixed invalidly escaped string --- src/teamwork.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/teamwork.sh b/src/teamwork.sh index 56709219..0240589c 100644 --- a/src/teamwork.sh +++ b/src/teamwork.sh @@ -123,7 +123,7 @@ teamwork::update_estimation() { response=$(curl -X "PUT" "$TEAMWORK_URI/projects/api/v1/tasks/$TEAMWORK_TASK_ID.json" \ -u "$TEAMWORK_API_TOKEN"':' \ -H 'Content-Type: application/json; charset=utf-8' \ - -d "{ \"todo-item\": { \"estimated-minutes\": \"${estimation//\"/}\" } }" ) + -d "{ \"todo-item\": { \"estimated-minutes\": $estimation } }" ) log::message "$response" } @@ -191,6 +191,7 @@ teamwork::pull_request_closed() { teamwork::remove_tag "PR Open" teamwork::remove_tag "PR Approved" teamwork::move_task_to_column "$BOARD_COLUMN_MERGED" + teamwork::update_estimation 0 else teamwork::add_comment " **$user** closed a PR without merging: **$pr_title** From d0d8f0fb8b598a622e07506ee0644efda3bbc229 Mon Sep 17 00:00:00 2001 From: Brandon Oldenhof Date: Mon, 27 Feb 2023 17:32:44 +0100 Subject: [PATCH 04/13] Added comment to PR when changes have been requested --- src/teamwork.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/teamwork.sh b/src/teamwork.sh index 0240589c..15d0e3fc 100644 --- a/src/teamwork.sh +++ b/src/teamwork.sh @@ -213,6 +213,15 @@ teamwork::pull_request_review_submitted() { # Only add a message if the PR has been approved if [ "$review_state" != "approved" ]; then teamwork::move_task_to_column "$BOARD_COLUMN_FEEDBACK" + teamwork::add_comment " +**$user** requested changes to the PR: **$pr_title** +[$pr_url]($pr_url) + +--- + +Review: **$review_state** +$comment +" elif [ "$review_state" == "approved" ]; then teamwork::add_comment " **$user** submitted a review to the PR: **$pr_title** From 3765471dec9308e4f438e88584af58cb07afe9a8 Mon Sep 17 00:00:00 2001 From: Brandon Oldenhof Date: Mon, 27 Feb 2023 17:34:21 +0100 Subject: [PATCH 05/13] Updated check to only apply when changes are requested --- src/teamwork.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/teamwork.sh b/src/teamwork.sh index 15d0e3fc..c51632c4 100644 --- a/src/teamwork.sh +++ b/src/teamwork.sh @@ -211,7 +211,7 @@ teamwork::pull_request_review_submitted() { local -r comment=$(github::get_review_comment) # Only add a message if the PR has been approved - if [ "$review_state" != "approved" ]; then + if [ "$review_state" == "changes_requested" ]; then teamwork::move_task_to_column "$BOARD_COLUMN_FEEDBACK" teamwork::add_comment " **$user** requested changes to the PR: **$pr_title** From 5f4f05789454b77e0f9241c65923a99bcc7801d3 Mon Sep 17 00:00:00 2001 From: Brandon Oldenhof Date: Wed, 10 May 2023 11:10:57 +0200 Subject: [PATCH 06/13] updated actions so comments are more to the point and contain less fluff --- src/teamwork.sh | 112 +++++++++++++++--------------------------------- 1 file changed, 35 insertions(+), 77 deletions(-) diff --git a/src/teamwork.sh b/src/teamwork.sh index c51632c4..8c2e198e 100644 --- a/src/teamwork.sh +++ b/src/teamwork.sh @@ -6,7 +6,7 @@ teamwork::get_task_id_from_body() { pat='tasks\/([0-9]{1,})' while [[ $body =~ $pat ]]; do - task_ids+=( "${BASH_REMATCH[1]}" ) + task_ids+=("${BASH_REMATCH[1]}") body=${body#*"${BASH_REMATCH[0]}"} done @@ -25,7 +25,7 @@ teamwork::get_project_id_from_task() { fi response=$( - curl "$TEAMWORK_URI/projects/api/v1/tasks/$task_id.json" -u "$TEAMWORK_API_TOKEN"':' |\ + curl "$TEAMWORK_URI/projects/api/v1/tasks/$task_id.json" -u "$TEAMWORK_API_TOKEN"':' | jq -r '.["todo-item"]["project-id"]' ) echo "$response" @@ -44,7 +44,7 @@ teamwork::get_matching_board_column_id() { fi response=$( - curl "$TEAMWORK_URI/projects/$TEAMWORK_PROJECT_ID/boards/columns.json" -u "$TEAMWORK_API_TOKEN"':' |\ + curl "$TEAMWORK_URI/projects/$TEAMWORK_PROJECT_ID/boards/columns.json" -u "$TEAMWORK_API_TOKEN"':' | jq -r --arg column_name "$column_name" '[.columns[] | select(.name | contains($column_name))] | map(.id)[0]' ) @@ -76,9 +76,9 @@ teamwork::move_task_to_column() { fi response=$(curl -X "PUT" "$TEAMWORK_URI/tasks/$TEAMWORK_TASK_ID.json" \ - -u "$TEAMWORK_API_TOKEN"':' \ - -H 'Content-Type: application/json; charset=utf-8' \ - -d "{ \"todo-item\": { \"columnId\": $column_id } }" ) + -u "$TEAMWORK_API_TOKEN"':' \ + -H 'Content-Type: application/json; charset=utf-8' \ + -d "{ \"todo-item\": { \"columnId\": $column_id } }") log::message "$response" } @@ -92,9 +92,9 @@ teamwork::add_comment() { fi response=$(curl -X "POST" "$TEAMWORK_URI/projects/api/v1/tasks/$TEAMWORK_TASK_ID/comments.json" \ - -u "$TEAMWORK_API_TOKEN"':' \ - -H 'Content-Type: application/json; charset=utf-8' \ - -d "{ \"comment\": { \"body\": \"${body//\"/}\", \"notify\": false, \"content-type\": \"text\", \"isprivate\": false } }" ) + -u "$TEAMWORK_API_TOKEN"':' \ + -H 'Content-Type: application/json; charset=utf-8' \ + -d "{ \"comment\": { \"body\": \"${body//\"/}\", \"notify\": false, \"content-type\": \"text\", \"isprivate\": false } }") log::message "$response" } @@ -109,9 +109,9 @@ teamwork::add_tag() { if [ "$AUTOMATIC_TAGGING" == true ]; then response=$(curl -X "PUT" "$TEAMWORK_URI/projects/api/v1/tasks/$TEAMWORK_TASK_ID/tags.json" \ - -u "$TEAMWORK_API_TOKEN"':' \ - -H 'Content-Type: application/json; charset=utf-8' \ - -d "{ \"tags\": { \"content\": \"${tag_name//\"/}\" } }" ) + -u "$TEAMWORK_API_TOKEN"':' \ + -H 'Content-Type: application/json; charset=utf-8' \ + -d "{ \"tags\": { \"content\": \"${tag_name//\"/}\" } }") log::message "$response" fi @@ -121,9 +121,9 @@ teamwork::update_estimation() { local -r estimation=$1 response=$(curl -X "PUT" "$TEAMWORK_URI/projects/api/v1/tasks/$TEAMWORK_TASK_ID.json" \ - -u "$TEAMWORK_API_TOKEN"':' \ - -H 'Content-Type: application/json; charset=utf-8' \ - -d "{ \"todo-item\": { \"estimated-minutes\": $estimation } }" ) + -u "$TEAMWORK_API_TOKEN"':' \ + -H 'Content-Type: application/json; charset=utf-8' \ + -d "{ \"todo-item\": { \"estimated-minutes\": $estimation } }") log::message "$response" } @@ -138,9 +138,9 @@ teamwork::remove_tag() { if [ "$AUTOMATIC_TAGGING" == true ]; then response=$(curl -X "PUT" "$TEAMWORK_URI/projects/api/v1/tasks/$TEAMWORK_TASK_ID/tags.json" \ - -u "$TEAMWORK_API_TOKEN"':' \ - -H 'Content-Type: application/json; charset=utf-8' \ - -d "{ \"tags\": { \"content\": \"${tag_name//\"/}\" },\"removeProvidedTags\":\"true\" }" ) + -u "$TEAMWORK_API_TOKEN"':' \ + -H 'Content-Type: application/json; charset=utf-8' \ + -d "{ \"tags\": { \"content\": \"${tag_name//\"/}\" },\"removeProvidedTags\":\"true\" }") log::message "$response" fi @@ -149,29 +149,10 @@ teamwork::remove_tag() { teamwork::pull_request_opened() { local -r pr_url=$(github::get_pr_url) local -r pr_title=$(github::get_pr_title) - local -r head_ref=$(github::get_head_ref) - local -r base_ref=$(github::get_base_ref) local -r user=$(github::get_sender_user) - local -r pr_stats=$(github::get_pr_patch_stats) - local -r pr_body=$(github::get_pr_body) - IFS=" " read -r -a pr_stats_array <<< "$pr_stats" - - teamwork::add_comment " -**$user** opened a PR: **$pr_title** -[$pr_url]($pr_url) -\`$base_ref\` ⬅️ \`$head_ref\` - ---- - -${pr_body} ---- + teamwork::add_comment "**$user** opened [$pr_title]($pr_url)" -🔢 ${pr_stats_array[0]} commits / 📝 ${pr_stats_array[1]} files updated / ➕ ${pr_stats_array[2]} additions / ➖ ${pr_stats_array[3]} deletions - - " - - teamwork::add_tag "PR Open" teamwork::move_task_to_column "$BOARD_COLUMN_OPENED" teamwork::update_estimation 15 } @@ -181,25 +162,23 @@ teamwork::pull_request_closed() { local -r pr_url=$(github::get_pr_url) local -r pr_title=$(github::get_pr_title) local -r pr_merged=$(github::get_pr_merged) + local -r pr_body=$(github::get_pr_body) if [ "$pr_merged" == "true" ]; then 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" - teamwork::update_estimation 0 + **$user** merged [$pr_title]($pr_url). + This feature is ready for testing by the client. + + --- + + ${pr_body} + + " + teamwork::move_task_to_column "$BOARD_COLUMN_MERGED" + teamwork::update_estimation 0 else - teamwork::add_comment " -**$user** closed a PR without merging: **$pr_title** -[$pr_url]($pr_url) -" - teamwork::remove_tag "PR Open" - teamwork::remove_tag "PR Approved" - teamwork::move_task_to_column "$BOARD_COLUMN_CLOSED" + teamwork::add_comment "**$user** closed [$pr_title]($pr_url) without merging." + teamwork::move_task_to_column "$BOARD_COLUMN_FEEDBACK" fi } @@ -208,36 +187,15 @@ teamwork::pull_request_review_submitted() { local -r pr_url=$(github::get_pr_url) local -r pr_title=$(github::get_pr_title) local -r review_state=$(github::get_review_state) - local -r comment=$(github::get_review_comment) - # Only add a message if the PR has been approved if [ "$review_state" == "changes_requested" ]; then teamwork::move_task_to_column "$BOARD_COLUMN_FEEDBACK" - teamwork::add_comment " -**$user** requested changes to the PR: **$pr_title** -[$pr_url]($pr_url) - ---- - -Review: **$review_state** -$comment -" - elif [ "$review_state" == "approved" ]; then - teamwork::add_comment " -**$user** submitted a review to the PR: **$pr_title** -[$pr_url]($pr_url) - ---- - -Review: **$review_state** -$comment -" - teamwork::add_tag "PR Approved" - teamwork::update_estimation 0 + teamwork::add_comment "**$user** requested changes to [$pr_title]($pr_url)" fi } teamwork::pull_request_review_dismissed() { local -r user=$(github::get_sender_user) - teamwork::add_comment "Review dismissed by $user" + teamwork::move_task_to_column "$BOARD_COLUMN_OPENED" + teamwork::add_comment "Review dismissed by **$user**" } From a2678fae2134bfc3b8e840d70521133e72728933 Mon Sep 17 00:00:00 2001 From: Brandon Oldenhof Date: Wed, 10 May 2023 11:51:15 +0200 Subject: [PATCH 07/13] Enabled notifications when a PR has been merged. Updated comment texts to be more consistent. --- src/teamwork.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/teamwork.sh b/src/teamwork.sh index 9d836336..b8501dea 100644 --- a/src/teamwork.sh +++ b/src/teamwork.sh @@ -85,6 +85,7 @@ teamwork::move_task_to_column() { teamwork::add_comment() { local -r body=$1 + local -r notify=$2:-false if [ "$ENV" == "test" ]; then log::message "Test - Simulate request. Task ID: $TEAMWORK_TASK_ID - Comment: ${body//\"/}" @@ -94,7 +95,7 @@ teamwork::add_comment() { response=$(curl -X "POST" "$TEAMWORK_URI/tasks/$TEAMWORK_TASK_ID/comments.json" \ -u "$TEAMWORK_API_TOKEN"':' \ -H 'Content-Type: application/json; charset=utf-8' \ - -d "{ \"comment\": { \"body\": \"${body//\"/}\", \"notify\": false, \"content-type\": \"text\", \"isprivate\": false } }") + -d "{ \"comment\": { \"body\": \"${body//\"/}\", \"notify\": $notify, \"content-type\": \"text\", \"isprivate\": false } }") log::message "$response" } @@ -151,7 +152,7 @@ teamwork::pull_request_opened() { local -r pr_title=$(github::get_pr_title) local -r user=$(github::get_sender_user) - teamwork::add_comment "**$user** opened [$pr_title]($pr_url)" + teamwork::add_comment "**$user** opened the [$pr_title]($pr_url) PR for this task." teamwork::move_task_to_column "$BOARD_COLUMN_OPENED" teamwork::update_estimation 15 @@ -166,18 +167,17 @@ teamwork::pull_request_closed() { if [ "$pr_merged" == "true" ]; then teamwork::add_comment " - **$user** merged [$pr_title]($pr_url). - This feature is ready for testing by the client. + **$user** merged the [$pr_title]($pr_url) PR for this task. --- ${pr_body} - " + " true teamwork::move_task_to_column "$BOARD_COLUMN_MERGED" teamwork::update_estimation 0 else - teamwork::add_comment "**$user** closed [$pr_title]($pr_url) without merging." + teamwork::add_comment "**$user** closed the [$pr_title]($pr_url) PR for this task." teamwork::move_task_to_column "$BOARD_COLUMN_FEEDBACK" fi } @@ -190,12 +190,12 @@ teamwork::pull_request_review_submitted() { if [ "$review_state" == "changes_requested" ]; then teamwork::move_task_to_column "$BOARD_COLUMN_FEEDBACK" - teamwork::add_comment "**$user** requested changes to [$pr_title]($pr_url)" + teamwork::add_comment "**$user** requested changes to the [$pr_title]($pr_url) PR for this task." fi } teamwork::pull_request_review_dismissed() { local -r user=$(github::get_sender_user) teamwork::move_task_to_column "$BOARD_COLUMN_OPENED" - teamwork::add_comment "Review dismissed by **$user**" + teamwork::add_comment "Review on the [$pr_title]($pr_url) PR for this task dismissed by **$user**." } From 6a8be36d3053d6fc77d92b1ca2ae9dbaa7f7e53a Mon Sep 17 00:00:00 2001 From: Brandon Oldenhof Date: Wed, 10 May 2023 11:59:13 +0200 Subject: [PATCH 08/13] bugfix: fixed buggy assignment of default value --- src/teamwork.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/teamwork.sh b/src/teamwork.sh index b8501dea..e487c09a 100644 --- a/src/teamwork.sh +++ b/src/teamwork.sh @@ -85,7 +85,7 @@ teamwork::move_task_to_column() { teamwork::add_comment() { local -r body=$1 - local -r notify=$2:-false + local -r notify="${2:-false}" if [ "$ENV" == "test" ]; then log::message "Test - Simulate request. Task ID: $TEAMWORK_TASK_ID - Comment: ${body//\"/}" From dc458a808a224e47af788f0ef372eb0b153e226d Mon Sep 17 00:00:00 2001 From: Brandon Oldenhof Date: Wed, 10 May 2023 12:18:55 +0200 Subject: [PATCH 09/13] Added new function to remove the task header from the PR body so we don't add it to a comment in TW --- src/github.sh | 8 +++++++- src/teamwork.sh | 11 ++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/github.sh b/src/github.sh index 726b906b..31f3549f 100644 --- a/src/github.sh +++ b/src/github.sh @@ -37,7 +37,7 @@ github::get_pr_title() { } github::get_pr_patch_stats() { - jq --raw-output '.pull_request | "\(.commits) \(.changed_files) \(.additions) \(.deletions)"' "$GITHUB_EVENT_PATH" + jq --raw-output '.pull_request | "\(.commits) \(.changed_files) \(.additions) \(.deletions)"' "$GITHUB_EVENT_PATH" } github::get_pr_merged() { @@ -59,3 +59,9 @@ github::get_review_comment() { github::print_all_data() { cat "$GITHUB_EVENT_PATH" } + +github::get_pr_body_without_task() { + local -r pr_body=$(github::get_pr_body) + local output=$(echo "$pr_body" | sed -E 's/#### Description of the changes(.*)/\n#### Description of the changes\1/g') + log::message "$output" +} diff --git a/src/teamwork.sh b/src/teamwork.sh index e487c09a..fecdd34b 100644 --- a/src/teamwork.sh +++ b/src/teamwork.sh @@ -163,17 +163,18 @@ teamwork::pull_request_closed() { local -r pr_url=$(github::get_pr_url) local -r pr_title=$(github::get_pr_title) local -r pr_merged=$(github::get_pr_merged) - local -r pr_body=$(github::get_pr_body) + local -r pr_body=$(github::get_pr_body_without_task) if [ "$pr_merged" == "true" ]; then teamwork::add_comment " - **$user** merged the [$pr_title]($pr_url) PR for this task. +**$user** merged the [$pr_url]($pr_url) PR for this task: - --- +--- - ${pr_body} +${pr_body} - " true +--- + " teamwork::move_task_to_column "$BOARD_COLUMN_MERGED" teamwork::update_estimation 0 else From 85b94871a4a71e3874110b8eac1cf130757d3605 Mon Sep 17 00:00:00 2001 From: Brandon Oldenhof Date: Wed, 10 May 2023 12:40:04 +0200 Subject: [PATCH 10/13] Updated filtering of TW task from PR body --- src/github.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/github.sh b/src/github.sh index 31f3549f..36cb7bed 100644 --- a/src/github.sh +++ b/src/github.sh @@ -62,6 +62,6 @@ github::print_all_data() { github::get_pr_body_without_task() { local -r pr_body=$(github::get_pr_body) - local output=$(echo "$pr_body" | sed -E 's/#### Description of the changes(.*)/\n#### Description of the changes\1/g') + local output=$(echo "$pr_body" | sed -n '/^#### Description/,$p') log::message "$output" } From bf8283936a4ff0cdd7b705cf2ee47c83f26a83e3 Mon Sep 17 00:00:00 2001 From: Brandon Oldenhof Date: Wed, 10 May 2023 12:44:32 +0200 Subject: [PATCH 11/13] Cleaned up comment formatting --- src/teamwork.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/teamwork.sh b/src/teamwork.sh index fecdd34b..15f5a653 100644 --- a/src/teamwork.sh +++ b/src/teamwork.sh @@ -169,11 +169,7 @@ teamwork::pull_request_closed() { teamwork::add_comment " **$user** merged the [$pr_url]($pr_url) PR for this task: ---- - ${pr_body} - ---- " teamwork::move_task_to_column "$BOARD_COLUMN_MERGED" teamwork::update_estimation 0 From eb8c68d97fdb1cb9ea6d375b267a9a67a435495c Mon Sep 17 00:00:00 2001 From: Brandon Oldenhof Date: Wed, 10 May 2023 12:50:55 +0200 Subject: [PATCH 12/13] Fixed comment showing URL instead of title of the PR --- src/teamwork.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/teamwork.sh b/src/teamwork.sh index 15f5a653..97062e1f 100644 --- a/src/teamwork.sh +++ b/src/teamwork.sh @@ -167,7 +167,7 @@ teamwork::pull_request_closed() { if [ "$pr_merged" == "true" ]; then teamwork::add_comment " -**$user** merged the [$pr_url]($pr_url) PR for this task: +**$user** merged the [$pr_title]($pr_url) PR for this task: ${pr_body} " From 771535db7b78464ac3f7300c2368fbb79ed6b919 Mon Sep 17 00:00:00 2001 From: Brandon Oldenhof Date: Wed, 1 Nov 2023 15:05:23 +0100 Subject: [PATCH 13/13] feature: add support for switching a PR from draft to ready-for-review --- src/main.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.sh b/src/main.sh index 12c71918..a1040e3c 100644 --- a/src/main.sh +++ b/src/main.sh @@ -56,6 +56,8 @@ main() { if [ "$event" == "pull_request" ] && [ "$action" == "opened" ]; then teamwork::pull_request_opened + elif [ "$event" == "pull_request" ] && [ "$action" == "ready_for_review" ]; then + teamwork::pull_request_opened elif [ "$event" == "pull_request" ] && [ "$action" == "closed" ]; then teamwork::pull_request_closed elif [ "$event" == "pull_request_review" ] && [ "$action" == "submitted" ]; then