Skip to content

Commit

Permalink
Feature: move board to "In Progress" when changes have been requested…
Browse files Browse the repository at this point in the history
… on PR. Updated actions to update task estimates when PR status changes
  • Loading branch information
BrandonOldenhof committed Feb 8, 2023
1 parent 6e7ee26 commit 6cbc597
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ jobs:
BOARD_COLUMN_OPENED: "PR Open"
BOARD_COLUMN_MERGED: "Ready to Test"
BOARD_COLUMN_CLOSED: "Rejected"
BOARD_COLUMN_FEEDBACK: "PR Open"
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ jobs:
BOARD_COLUMN_OPENED: 'PR Open'
BOARD_COLUMN_MERGED: 'Ready to Test'
BOARD_COLUMN_CLOSED: 'Rejected'
BOARD_COLUMN_FEEDBACK: 'PR Open'
env:
IGNORE_PROJECT_IDS: '1 2 3'

Expand All @@ -75,6 +76,7 @@ You may also specify columns you'd like the task to be moved to on every stage o
- `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
- `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
- `BOARD_COLUMN_FEEDBACK`: The case-sensitive column name of the column you would like the task to be moved to when the PR receives feedback

The column names will be checked against all board columns in the task's project, this will be using a `contains()` method so you may specify part of the name instead of the full name, however this `contains()` check is case-sensitive. The first matching column will be used.

Expand Down
13 changes: 9 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,23 @@ inputs:
required: true
AUTOMATIC_TAGGING:
description: 'Do you want to enable automatic tagging: true/false'
required: false
required: true
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
default: ''
default: 'Testing ROX'
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
default: ''
default: 'Testing klant/PO'
BOARD_COLUMN_CLOSED:
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: ''
default: 'To do'
BOARD_COLUMN_FEEDBACK:
description: 'The case-sensitive column name of the column you would like the task to be moved to when the PR receives feedback'
required: false
default: 'In progress'
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.BOARD_COLUMN_FEEDBACK }}
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 BOARD_COLUMN_FEEDBACK="$8"

env::set_environment

Expand Down
17 changes: 16 additions & 1 deletion src/teamwork.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,17 @@ teamwork::add_tag() {
fi
}

teamwork::update_estimation() {
local -r estimation=$1

response=$(curl -X "PUT" "$TEAMWORK_URI/projects/api/v1/tasks/$TEAMWORK_TASK_ID.json" \
-u "$TEAMWORK_API_TOKEN"':' \
-H 'Content-Type: application/json; charset=utf-8' \
-d "{ \"todo-item\": { \"estimated-minutes\": \"${estimation//\"/}\" } }" )

log::message "$response"
}

teamwork::remove_tag() {
local -r tag_name=$1

Expand Down Expand Up @@ -162,6 +173,7 @@ ${pr_body}

teamwork::add_tag "PR Open"
teamwork::move_task_to_column "$BOARD_COLUMN_OPENED"
teamwork::update_estimation 15
}

teamwork::pull_request_closed() {
Expand Down Expand Up @@ -198,7 +210,9 @@ teamwork::pull_request_review_submitted() {
local -r comment=$(github::get_review_comment)

# Only add a message if the PR has been approved
if [ "$review_state" == "approved" ]; then
if [ "$review_state" != "approved" ]; then
teamwork::move_task_to_column "$BOARD_COLUMN_FEEDBACK"
elif [ "$review_state" == "approved" ]; then
teamwork::add_comment "
**$user** submitted a review to the PR: **$pr_title**
[$pr_url]($pr_url)
Expand All @@ -209,6 +223,7 @@ Review: **$review_state**
$comment
"
teamwork::add_tag "PR Approved"
teamwork::update_estimation 0
fi
}

Expand Down

0 comments on commit 6cbc597

Please sign in to comment.