Skip to content

Hello, this is an amazing title, Fixes AB#1234 #52

Hello, this is an amazing title, Fixes AB#1234

Hello, this is an amazing title, Fixes AB#1234 #52

Workflow file for this run

# This workflow detects if the AB validation check has succeeded
# (It is considered a success when a comment is posted with the code lcc-200),
# If a success message has been posted by the plugin (https://github.com/marketplace/actions/azure-boards-check-for-ab),
# The workflow will extract the AB ID from the message
# then it will update the PR title adding ',Fixed AB#ID' at the end.
# Why?
# Adding ',Fixed AB#ID' to the PR title will make the PR to automatically resolve the associated ADO item when the PR is completed.
name: "Append 'Fix AB#ID' to PR title"
# Triggers the workflow when a new issue comment is created
on:
issue_comment:
types: [created]
jobs:
# This job assert that:
# 1- The comment is on a pull request
# 2- The comment contains the string 'lcc-200'
# 3- The PR does not contains the 'skip AB ID validation' label
validation:
runs-on: ubuntu-latest
if: |
github.event.issue.pull_request &&
contains(github.event.comment.body, 'lcc-200') &&
!contains(github.event.issue.labels.*.name, 'skip AB ID validation')
steps:
- name: Check if workflow needs to be triggered
run: echo "Trigger workflow"
# Get AB#ID
get_ab_id:
runs-on: ubuntu-latest
needs: validation
outputs:
abid: ${{ steps.get.outputs.id }}
steps:
# Extracts the AB ID from the comment body using regex and store the result using outputs
- name: Get AB ID from comment
id: get
run: |
result=$(echo "${{ github.event.comment.body }}" | grep -oP '(?<=#)\d+')
echo "id=${result}" >> "$GITHUB_OUTPUT"