Skip to content

Create ADO user story from GitHub issue #2

Create ADO user story from GitHub issue

Create ADO user story from GitHub issue #2

name: Create ADO user story from GitHub issue
on:
issues:
types: [opened]
jobs:
create-ado-story:
runs-on: ubuntu-latest
steps:
- name: Build payload and call Azure DevOps
env:
ADO_ORG: ${{ secrets.ADO_ORG }}
ADO_PROJECT: ${{ secrets.ADO_PROJECT }}
ADO_PAT: ${{ secrets.ADO_PAT }}
DRI_CONTACT: ${{ secrets.DRI_CONTACT }}
ISSUE_TITLE: ${{ github.event.issue.title }}
ISSUE_BODY: ${{ github.event.issue.body }}
ISSUE_URL: ${{ github.event.issue.html_url }}
run: |
# Azure Boards uses HTML in the Description field.
DESCRIPTION="<div><a href=\"$ISSUE_URL\">$ISSUE_URL</a><br/><br/>${ISSUE_BODY//$'\n'/<br/>}</div>"
cat >/tmp/payload.json <<EOF
[
{ "op": "add", "path": "/fields/System.Title", "value": "$ISSUE_TITLE" },
{ "op": "add", "path": "/fields/System.Description", "value": "$DESCRIPTION" },
{ "op": "add", "path": "/fields/System.AreaPath", "value": "Content\\\\Production\\\\Core AI\\\\AI Services\\\\AI Agents" },
{ "op": "add", "path": "/fields/System.IterationPath","value": "Content" },
{ "op": "add", "path": "/fields/System.AssignedTo", "value": "$DRI_CONTACT" },
{ "op": "add", "path": "/fields/System.Tags", "value": "agents-doc-feedback" }
]
EOF
# Azure DevOps expects basic-auth; username can be blank.
AUTH=$(echo -n ":$ADO_PAT" | base64)
curl -sS \
-H "Content-Type: application/json-patch+json" \
-H "Authorization: Basic $AUTH" \
--request POST \
--data-binary @/tmp/payload.json \
"https://dev.azure.com/${ADO_ORG}/${ADO_PROJECT}/_apis/wit/workitems/\$User%20Story?api-version=7.1-preview.3"