Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature - Private comments #60

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
TEAMWORK_URI: "localhost"
TEAMWORK_API_TOKEN: "test_api_token"
AUTOMATIC_TAGGING: true
MAKE_COMMENTS_PRIVATE: true
BOARD_COLUMN_OPENED: "PR Open"
BOARD_COLUMN_MERGED: "Ready to Test"
BOARD_COLUMN_CLOSED: "Rejected"
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ jobs:
TEAMWORK_URI: ${{ secrets.TEAMWORK_URI }}
TEAMWORK_API_TOKEN: ${{ secrets.TEAMWORK_API_TOKEN }}
AUTOMATIC_TAGGING: false
MAKE_COMMENTS_PRIVATE: false
BOARD_COLUMN_OPENED: 'PR Open'
BOARD_COLUMN_MERGED: 'Ready to Test'
BOARD_COLUMN_CLOSED: 'Rejected'
Expand All @@ -71,6 +72,8 @@ Tags are added automatically on the task if you are have the option `AUTOMATIC_T
- A PR is merged: tags `PR Open` and `PR Approved` removed, tag `PR merged` added
- A PR is closed: tags `PR Open` and `PR Approved` removed

Using the `MAKE_COMMENTS_PRIVATE` flag, you can also optionally set all comments on Teamwork to be private to your organisation.

You may also specify columns you'd like the task to be moved to on every stage of the PR:
- `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
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ inputs:
AUTOMATIC_TAGGING:
description: 'Do you want to enable automatic tagging: true/false'
required: false
MAKE_COMMENTS_PRIVATE:
description: 'Do you want to make all comments private to your organisation: true/false'
required: false
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
Expand All @@ -36,6 +39,7 @@ runs:
- ${{ inputs.TEAMWORK_URI }}
- ${{ inputs.TEAMWORK_API_TOKEN }}
- ${{ inputs.AUTOMATIC_TAGGING }}
- ${{ inputs.MAKE_COMMENTS_PRIVATE }}
- ${{ inputs.BOARD_COLUMN_OPENED }}
- ${{ inputs.BOARD_COLUMN_MERGED }}
- ${{ inputs.BOARD_COLUMN_CLOSED }}
7 changes: 4 additions & 3 deletions src/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ main() {
export TEAMWORK_URI="$2"
export TEAMWORK_API_TOKEN="$3"
export AUTOMATIC_TAGGING="$4"
export BOARD_COLUMN_OPENED="$5"
export BOARD_COLUMN_MERGED="$6"
export BOARD_COLUMN_CLOSED="$7"
export MAKE_COMMENTS_PRIVATE="$5"
export BOARD_COLUMN_OPENED="$6"
export BOARD_COLUMN_MERGED="$7"
export BOARD_COLUMN_CLOSED="$8"

env::set_environment

Expand Down
11 changes: 10 additions & 1 deletion src/teamwork.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,16 @@ 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\": true, \"content-type\": \"text\", \"isprivate\": false } }" )
-d "{
\"comment\": {
\"body\": \"${body//\"/}\",
\"notify\": true,
\"content-type\":
\"text\",
\"isprivate\": $([ "$MAKE_COMMENTS_PRIVATE" == true ] && echo true || echo false)
}
}"
)

log::message "$response"
}
Expand Down