diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4bab5c6c..4fb67741 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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" diff --git a/README.md b/README.md index 3c54c77b..80e2e942 100644 --- a/README.md +++ b/README.md @@ -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' @@ -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 diff --git a/action.yml b/action.yml index f704b08a..5e947eb6 100644 --- a/action.yml +++ b/action.yml @@ -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 @@ -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 }} diff --git a/src/main.sh b/src/main.sh index cf553262..d2cd4c5a 100644 --- a/src/main.sh +++ b/src/main.sh @@ -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 diff --git a/src/teamwork.sh b/src/teamwork.sh index b3c5e687..7d4b24ef 100644 --- a/src/teamwork.sh +++ b/src/teamwork.sh @@ -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" }