DevOps-Update work item state
Update work item state

Update work item state when Pull Request is merged.

What does it do?

When a pull request is merged to the target branch, the action will trigger a workflow to update the linked work items state to its next state. For example, if the Work Item's state is in ToDo, the work item's state will change to doing. The action supports both default and custom process templates as well.

Updating work item state in Azure DevOps 🔁 when the pull request is merged.


Supported Pull Request 🔃 States

The action currently supports closed state. Support for other pull request states will be added soon.


  1. Azure DevOps account
  2. Azure DevOps PAT
  3. GitHub Account
  4. GitHub PAT
  5. Install the Azure Boards App from GitHub Marketplace

Example Usage

  1. Add the following as GitHub secrets in your repository.

    • Azure DevOps PAT
    • GitHub PAT
    • Azure DevOps Organization
    • Azure DevOps Project

  2. Other Input Parameters

    • closedstate- This Parameter is required for the action to check the workitem state. If the target workitem's state is closed, the action will quit. This is to ensure that a closed work item is not linked to a pull request.

    • gh_repo, gh_repo_owner- To get the latest pull request details

    • pull_number- value of this parameter is obtained from the GitHub event ${{github.event.number}}

WorkFlow Process

  1. Get the Work Item Id

    • With the github repository inputs, a request is sent to the pull request api endpoint to get the complete pull request details

    • From the pull request details the work item id is retrieved

  2. Update the Work Item State

    • With the Work Item and the ADO Project Name, the work item states associated with the Project are pulled.

    • At first, the check will be done whether the work item is in closed state. If not, the workitem state is updated to the next state.

Link the Work Item

The work Item Id must be prefixed with AB and added as AB#[Workitem Id] in the Pull request body. Linking your workitem in your pull request is mandatory, if no workitem is found the action will produce an error.


Sample WorkFlow File

name: Update work item state when PR is merged

                        branches: [master]
                        types: [closed]

                        runs-on: ubuntu-latest
                        name: Test workflow
    - uses: CanarysAutomations/pr-update-work-item-state@master
                        gh_token : '${{ secrets.GH_TOKEN }}'   
                        ado_token: '${{ secrets.ADO_PERSONAL_ACCESS_TOKEN }}'
                        ado_organization: '${{ secrets.ADO_ORGANIZATION }}'
                        ado_project: '${{ secrets.ADO_PROJECT }}'
                        closedstate: ''
                        gh_repo_owner: ''
                        gh_repo: ''
                        pull_number: '${{github.event.number}}' 

You can reach us Contact Us for more information.