forked from ryankilroy/trackfacto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
storycize.sh
executable file
·20 lines (15 loc) · 1.36 KB
/
storycize.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env bash
set -e
[ -z "$PF_RETRO_NAME" ] && echo 'Please set the retro name ($PF_RETRO_NAME)' && exit 1
[ -z "$PF_BEARER_TOKEN" ] && echo 'Please set the retro bearer token ($PF_BEARER_TOKEN)' && exit 1
[ -z "$TRACKER_PROJECT_ID" ] && echo 'Please set the tracker project id ($TRACKER_PROJECT_ID)' && exit 1
[ -z "$TRACKER_API_TOKEN" ] && echo 'Please set the retro name ($TRACKER_API_TOKEN)' && exit 1
items=$(curl "https://retro-api.cfapps.io/retros/$PF_RETRO_NAME" -H "authorization: Bearer $PF_BEARER_TOKEN" | jq -r '.retro.action_items' | jq -r 'map(select(.done == false))' | jq -r 'map({id,description})| .[] | @base64')
for item in $(echo ${items}); do
story=$(echo ${item} | base64 --decode | jq -r '.description')
echo "Adding story '$story' to tracker"
curl -X POST -H "X-TrackerToken: $TRACKER_API_TOKEN" -H "Content-Type: application/json" -d "{\"name\":\"$story\", \"story_type\":\"chore\", \"labels\":[\"action-item\"]}" "https://www.pivotaltracker.com/services/v5/projects/$TRACKER_PROJECT_ID/stories"
story_id=$(echo ${item} | base64 --decode | jq -r '.id')
echo "Finishing action item '$story' in Postfacto"
curl "https://retro-api.cfapps.io/retros/oslo/action_items/$story_id" -X PATCH -H "authorization: Bearer $PF_BEARER_TOKEN" -H 'Content-Type: application/json' -H 'accept: application/json' --data-binary '{"done":true}' --compressed
done