Skip to content

Commit b8160cc

Browse files
Add the ability for comments to be optionally private
1 parent 01c7592 commit b8160cc

File tree

5 files changed

+22
-4
lines changed

5 files changed

+22
-4
lines changed

.github/workflows/test.yml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
TEAMWORK_URI: "localhost"
1818
TEAMWORK_API_TOKEN: "test_api_token"
1919
AUTOMATIC_TAGGING: true
20+
MAKE_COMMENTS_PRIVATE: true
2021
BOARD_COLUMN_OPENED: "PR Open"
2122
BOARD_COLUMN_MERGED: "Ready to Test"
2223
BOARD_COLUMN_CLOSED: "Rejected"

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ jobs:
4848
TEAMWORK_URI: ${{ secrets.TEAMWORK_URI }}
4949
TEAMWORK_API_TOKEN: ${{ secrets.TEAMWORK_API_TOKEN }}
5050
AUTOMATIC_TAGGING: false
51+
MAKE_COMMENTS_PRIVATE: false
5152
BOARD_COLUMN_OPENED: 'PR Open'
5253
BOARD_COLUMN_MERGED: 'Ready to Test'
5354
BOARD_COLUMN_CLOSED: 'Rejected'
@@ -71,6 +72,8 @@ Tags are added automatically on the task if you are have the option `AUTOMATIC_T
7172
- A PR is merged: tags `PR Open` and `PR Approved` removed, tag `PR merged` added
7273
- A PR is closed: tags `PR Open` and `PR Approved` removed
7374

75+
Using the `MAKE_COMMENTS_PRIVATE` flag, you can also optionally set all comments on Teamwork to be private to your organisation.
76+
7477
You may also specify columns you'd like the task to be moved to on every stage of the PR:
7578
- `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
7679
- `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

action.yml

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ inputs:
1616
AUTOMATIC_TAGGING:
1717
description: 'Do you want to enable automatic tagging: true/false'
1818
required: false
19+
MAKE_COMMENTS_PRIVATE:
20+
description: 'Do you want to make all comments private to your organisation: true/false'
21+
required: false
1922
BOARD_COLUMN_OPENED:
2023
description: 'The case-sensitive column name of the column you would like the task to be moved to once the PR has been opened'
2124
required: false
@@ -36,6 +39,7 @@ runs:
3639
- ${{ inputs.TEAMWORK_URI }}
3740
- ${{ inputs.TEAMWORK_API_TOKEN }}
3841
- ${{ inputs.AUTOMATIC_TAGGING }}
42+
- ${{ inputs.MAKE_COMMENTS_PRIVATE }}
3943
- ${{ inputs.BOARD_COLUMN_OPENED }}
4044
- ${{ inputs.BOARD_COLUMN_MERGED }}
4145
- ${{ inputs.BOARD_COLUMN_CLOSED }}

src/main.sh

+4-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ main() {
1717
export TEAMWORK_URI="$2"
1818
export TEAMWORK_API_TOKEN="$3"
1919
export AUTOMATIC_TAGGING="$4"
20-
export BOARD_COLUMN_OPENED="$5"
21-
export BOARD_COLUMN_MERGED="$6"
22-
export BOARD_COLUMN_CLOSED="$7"
20+
export MAKE_COMMENTS_PRIVATE="$5"
21+
export BOARD_COLUMN_OPENED="$6"
22+
export BOARD_COLUMN_MERGED="$7"
23+
export BOARD_COLUMN_CLOSED="$8"
2324

2425
env::set_environment
2526

src/teamwork.sh

+10-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,16 @@ teamwork::add_comment() {
9494
response=$(curl -X "POST" "$TEAMWORK_URI/tasks/$TEAMWORK_TASK_ID/comments.json" \
9595
-u "$TEAMWORK_API_TOKEN"':' \
9696
-H 'Content-Type: application/json; charset=utf-8' \
97-
-d "{ \"comment\": { \"body\": \"${body//\"/}\", \"notify\": true, \"content-type\": \"text\", \"isprivate\": false } }" )
97+
-d "{
98+
\"comment\": {
99+
\"body\": \"${body//\"/}\",
100+
\"notify\": true,
101+
\"content-type\":
102+
\"text\",
103+
\"isprivate\": $([ "$MAKE_COMMENTS_PRIVATE" == true ] && echo true || echo false)
104+
}
105+
}"
106+
)
98107

99108
log::message "$response"
100109
}

0 commit comments

Comments
 (0)