Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
ttizze committed Jul 27, 2024
1 parent 24119ce commit 1551163
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion .github/workflows/link-pr-to-issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ name: Link PR to Issue
on:
pull_request:
types: [opened]
workflow_dispatch:
inputs:
pr_number:
description: 'Pull Request number'
required: true

jobs:
link_pr_to_issue:
Expand All @@ -11,7 +16,12 @@ jobs:
- name: Extract issue number from branch name
id: extract-issue
run: |
BRANCH_NAME="${{ github.head_ref }}"
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
PR_NUMBER="${{ github.event.inputs.pr_number }}"
BRANCH_NAME=$(gh pr view $PR_NUMBER --json headRefName -q .headRefName)
else
BRANCH_NAME="${{ github.head_ref }}"
fi
ISSUE_NUMBER=$(echo $BRANCH_NAME | grep -oP 'issue-\K\d+' || true)
if [ -z "$ISSUE_NUMBER" ]; then
echo "No issue number found in branch name. Workflow will exit."
Expand Down

0 comments on commit 1551163

Please sign in to comment.