Workflow action-#1 #5
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Link Commits to Issues | |
on: | |
pull_request: | |
types: [opened, edited, reopened, synchronize] | |
jobs: | |
link-issues: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repository | |
uses: actions/checkout@v2 | |
- name: Link Issues Based on Branch or PR Title | |
run: | | |
ISSUE_KEY=$(echo "${{ github.head_ref }}" | grep -Eo '[A-Z]+-[0-9]+') || true | |
if [ -z "$ISSUE_KEY" ]; then | |
ISSUE_KEY=$(echo "${{ github.event.pull_request.title }}" | grep -Eo '[A-Z]+-[0-9]+') || true | |
fi | |
if [ ! -z "$ISSUE_KEY" ]; then | |
echo "Found issue key: $ISSUE_KEY" | |
curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "Content-Type: application/json" \ | |
-d "{\"body\": \"Linked to $ISSUE_KEY\"}" \ | |
${{ github.event.pull_request.issue_url }} | |
else | |
echo "No issue key found in branch name or PR title." | |
fi | |