diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4bab5c6c..2cf0c85f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,7 +16,8 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} TEAMWORK_URI: "localhost" TEAMWORK_API_TOKEN: "test_api_token" - AUTOMATIC_TAGGING: true BOARD_COLUMN_OPENED: "PR Open" + BOARD_COLUMN_APPROVED: 'PR Approved' + BOARD_COLUMN_CHANGES_REQUESTED: 'Changes Requested' BOARD_COLUMN_MERGED: "Ready to Test" BOARD_COLUMN_CLOSED: "Rejected" diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..9f11b755 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ diff --git a/README.md b/README.md index 3c54c77b..96e6a151 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,8 @@ jobs: TEAMWORK_API_TOKEN: ${{ secrets.TEAMWORK_API_TOKEN }} AUTOMATIC_TAGGING: false BOARD_COLUMN_OPENED: 'PR Open' + BOARD_COLUMN_APPROVED: 'PR Approved' + BOARD_COLUMN_CHANGES_REQUESTED: 'Changes Requested' BOARD_COLUMN_MERGED: 'Ready to Test' BOARD_COLUMN_CLOSED: 'Rejected' env: @@ -73,6 +75,8 @@ Tags are added automatically on the task if you are have the option `AUTOMATIC_T 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_APPROVED`: The case-sensitive column name of the column you'd like the task to be moved to once the PR has been approved +- `BOARD_COLUMN_CHANGES_REQUESTED`: The case-sensitive column name of the column you'd like the task to be moved to once the PR has changes requested - `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 diff --git a/action.yml b/action.yml index f704b08a..33a1659a 100644 --- a/action.yml +++ b/action.yml @@ -20,6 +20,14 @@ inputs: 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: '' + BOARD_COLUMN_APPROVED: + description: 'The case-sensitive column name of the column you would like the task to be moved to once the PR has been approved' + required: false + default: '' + BOARD_COLUMN_CHANGES_REQUESTED: + description: 'The case-sensitive column name of the column you would like the task to be moved to once the PR has changes requested' + required: false + default: '' 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 @@ -37,5 +45,7 @@ runs: - ${{ inputs.TEAMWORK_API_TOKEN }} - ${{ inputs.AUTOMATIC_TAGGING }} - ${{ inputs.BOARD_COLUMN_OPENED }} + - ${{ inputs.BOARD_COLUMN_APPROVED }} + - ${{ inputs.BOARD_COLUMN_CHANGES_REQUESTED }} - ${{ inputs.BOARD_COLUMN_MERGED }} - ${{ inputs.BOARD_COLUMN_CLOSED }} diff --git a/src/main.sh b/src/main.sh index cf553262..b04df883 100644 --- a/src/main.sh +++ b/src/main.sh @@ -18,8 +18,10 @@ main() { 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 BOARD_COLUMN_APPROVED="$6" + export BOARD_COLUMN_CHANGES_REQUESTED="$7" + export BOARD_COLUMN_MERGED="$8" + export BOARD_COLUMN_CLOSED="$9" env::set_environment diff --git a/src/teamwork.sh b/src/teamwork.sh index b3c5e687..10081b72 100644 --- a/src/teamwork.sh +++ b/src/teamwork.sh @@ -209,6 +209,19 @@ Review: **$review_state** $comment " teamwork::add_tag "PR Approved" + teamwork::move_task_to_column "$BOARD_COLUMN_APPROVED" + elif [ "$review_state" == "changes_requested" ]; then + teamwork::add_comment " +**$user** requested changes to the PR: **$pr_title** +[$pr_url]($pr_url) + +--- + +Review: **$review_state** +$comment +" + teamwork::add_tag "PR Changes Requested" + teamwork::move_task_to_column "$BOARD_COLUMN_CHANGES_REQUESTED" fi } diff --git a/tests/events/pull_request_changes_requested.json b/tests/events/pull_request_changes_requested.json new file mode 100644 index 00000000..c17b124d --- /dev/null +++ b/tests/events/pull_request_changes_requested.json @@ -0,0 +1,21 @@ +{ + "action": "submitted", + "number": 1, + "pull_request": { + "body": "This is the body of the PR. https://xxxx.teamwork.com/#/tasks/123 https://xxx.teamwork.com/#/tasks/456", + "head": { + "repo": { + "full_name": "teamwork/github-sync" + } + }, + "html_url": "https://github.com/teamwork/github-sync/pull/2", + "title": "This is an example of a title for the PR." + }, + "review": { + "state": "changes_requested", + "body": "This is the comment of the review." + }, + "sender": { + "login": "username" + } +}