Skip to content

Dummy Harvestr Ticket #11

Dummy Harvestr Ticket

Dummy Harvestr Ticket #11

name: Harvestr Updates (Feedback)
on:
issues:
# listen for key events that indicate a change in the issue's lifecycle
types: [assigned, closed, milestoned, demilestoned]
jobs:
update-harvestr:
runs-on: ubuntu-latest
steps:
- name: Find comment matching a regex pattern
uses: peter-evans/find-comment@b30e6a3c0ed37e7c023ccd3f1db5c6c0b0c23aad
id: find_comment
with:
issue-number: ${{ github.event.issue.number }}
body-includes: "Issue was linked to Harvestr Discovery"
# if updated issue is linked Harvestr Discovery, update the discovery state based on the issue lifecycle event
- name: Update Harvestr Discovery
if: steps.find_comment.outputs.comment-id != 0
shell: bash
env:
HARVESTR_API_KEY: ${{ secrets.HARVESTR_API_KEY }}
COMMENT_BODY: ${{ steps.find_comment.outputs.comment-body }}
run: |
echo "DEBUG: ${COMMENT_BODY}"
HARVEST_ID=$(echo "${COMMENT_BODY}" | sed -n 's/.*list\/\(.*\))/\1/p')
echo "Found ID: ${HARVEST_ID}"
echo "Action: ${{ github.event.action }}"
function updateState() {
local state="$1"
echo "Updating Harvestr item ${HARVEST_ID} to state: ${state} via https://rest.harvestr.io/v1/discovery/${HARVEST_ID}"
curl --proto "=https"-LX PATCH "https://rest.harvestr.io/v1/discovery/${HARVEST_ID}" \
-H "X-Harvestr-Private-App-Token: ${HARVESTR_API_KEY}" \
-H "Content-Type: application/json" \
-H 'Accept: application/json' \
-d "{\"discoveryStateId\": \"${state}\"}"
}
# Disco States from Harvestr
# Planned eRnRKMd0dVd
# New ga3xFjA7FHO
# Not for now 0PtZSDdq2pZ
# Shipped HKxdJwUCJKQ
# In Progress z5tLYR4dHDW
case "${{ github.event.action }}" in
"assigned")
# In Progress z5tLYR4dHDW
updateState "z5tLYR4dHDW" ;;
"closed")
# Shipped HKxdJwUCJKQ
updateState "HKxdJwUCJKQ" ;;
"milestoned")
# Planned eRnRKMd0dVd
updateState "eRnRKMd0dVd" ;;
"demilestoned")
# New ga3xFjA7FHO
updateState "ga3xFjA7FHO" ;;
esac
echo "Harvestr item ${HARVEST_ID} updated successfully."