Use this action to check your pull request to make sure it is linked to a work item using AB#
before you can merge.
Click here to see the action in the GitHub marketplace.
Make sure the GitHub repository is properly linked to an Azure DevOps project. The following docs will help you get started and setup:
- Learn about the Azure Boards - GitHub integration
- Install the Azure Boards app
- Connect a GitHub repository to Azure Boards
- Link GitHub commits and pull requests to work items in Azure Boards
The action will check the pull request description for AB#
and a valid work item id. If it finds a valid work item id, it will pass. If it does not find a valid work item id, it will fail.
If the sender is dependabot[bot]
the action will ignore the check.
demo-ab-check.mp4
You might get an error whent the action is run. If you open the error log and see something like this:
"Error: Resource not accessible by integration"
To fix this, go to https://github.com/{owner}/{repo}/settings/actions
and in Workflow Permissions section give actions Read and Write permissions. That provides the token with rights to modify your repo and solves your problem.
We use a series of code values to mark and check previous comments to ensure the actions does not get too chatty after each run. For example, if you don't add AB#{ID}
to the description, we don't need to tell you every time you update the desciption. We will only tell you once untill something changes.
Successfully found a valid work item id in the pull request description.
Missing AB#
in the pull request description.
Found AB#
but the work item id is not valid.
This is the main workflow file. It will run on any pull request that is opened, reopened, or edited. It will only run on the main
branch. This file needs to be added to the .github/workflows
folder in your repository.
name: 'Description contains AB# with a valid work item id'
on: # rebuild any PRs for main branch changes
pull_request:
types: [opened, reopened, edited]
branches:
- main
jobs:
create-edit-comment:
name: check
runs-on: ubuntu-latest
steps:
- uses: danhellem/github-actions-pr-is-linked-to-work-item@main