Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -39,3 +43,4 @@ runs:
- ${{ inputs.BOARD_COLUMN_OPENED }}
- ${{ inputs.BOARD_COLUMN_MERGED }}
- ${{ inputs.BOARD_COLUMN_CLOSED }}
- ${{ inputs.LIGHTWEIGHT_COMMENT }}
1 change: 1 addition & 0 deletions src/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
34 changes: 25 additions & 9 deletions src/teamwork.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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\`
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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)

Expand All @@ -208,6 +223,7 @@ teamwork::pull_request_review_submitted() {
Review: **$review_state**
$comment
"
fi
teamwork::add_tag "PR Approved"
fi
}
Expand Down