Skip to content

Commit 5069b41

Browse files
moonbox3github-actions[bot]CopilotMAF Dashboard BotCopilot
authored
Simplify PR parsing for automated review workflow (#13689)
### Motivation and Context Improve PR parsing by just operating on the PR number - no need for a full URL. <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [ ] The code builds clean without any errors or warnings - [ ] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [ ] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄 --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: MAF Dashboard Bot <maf-dashboard-bot@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent f034ed1 commit 5069b41

1 file changed

Lines changed: 13 additions & 25 deletions

File tree

.github/workflows/devflow-pr-review.yml

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ on:
88
- ready_for_review
99
workflow_dispatch:
1010
inputs:
11-
pr_url:
12-
description: Pull request URL to review
11+
pr_number:
12+
description: Pull request number to review
1313
required: true
1414
type: string
1515

@@ -40,39 +40,27 @@ jobs:
4040
shell: bash
4141
env:
4242
PR_HTML_URL: ${{ github.event.pull_request.html_url }}
43-
PR_NUMBER: ${{ github.event.pull_request.number }}
44-
PR_URL_INPUT: ${{ inputs.pr_url }}
43+
PR_NUMBER_EVENT: ${{ github.event.pull_request.number }}
44+
PR_NUMBER_INPUT: ${{ inputs.pr_number }}
4545
run: |
4646
set -euo pipefail
4747
4848
if [[ "${GITHUB_EVENT_NAME}" == "pull_request_target" ]]; then
49-
echo "pr_url=${PR_HTML_URL}" >> "$GITHUB_OUTPUT"
50-
echo "pr_number=${PR_NUMBER}" >> "$GITHUB_OUTPUT"
51-
echo "repo=${GITHUB_REPOSITORY}" >> "$GITHUB_OUTPUT"
52-
exit 0
49+
pr_number="${PR_NUMBER_EVENT}"
50+
pr_url="${PR_HTML_URL}"
51+
else
52+
pr_number="${PR_NUMBER_INPUT}"
53+
pr_url="https://github.com/${GITHUB_REPOSITORY}/pull/${pr_number}"
5354
fi
5455
55-
if [[ -z "$PR_URL_INPUT" ]]; then
56-
echo "workflow_dispatch requires pr_url" >&2
56+
if [[ ! "$pr_number" =~ ^[1-9][0-9]*$ ]]; then
57+
echo "Could not determine PR number; for workflow_dispatch runs, the 'pr_number' input is required when not running on pull_request_target." >&2
5758
exit 1
5859
fi
5960
60-
if [[ ! "$PR_URL_INPUT" =~ ^https://github\.com/([^/]+/[^/]+)/pull/([0-9]+)([/?].*)?$ ]]; then
61-
echo "Could not parse pull request URL (expected https://github.com/<owner>/<repo>/pull/<number>): $PR_URL_INPUT" >&2
62-
exit 1
63-
fi
64-
65-
pr_repo="${BASH_REMATCH[1]}"
66-
pr_number="${BASH_REMATCH[2]}"
67-
68-
if [[ "$pr_repo" != "$GITHUB_REPOSITORY" ]]; then
69-
echo "PR URL repository ($pr_repo) does not match current repository ($GITHUB_REPOSITORY)" >&2
70-
exit 1
71-
fi
72-
73-
echo "pr_url=${PR_URL_INPUT}" >> "$GITHUB_OUTPUT"
61+
echo "pr_url=${pr_url}" >> "$GITHUB_OUTPUT"
7462
echo "pr_number=${pr_number}" >> "$GITHUB_OUTPUT"
75-
echo "repo=${pr_repo}" >> "$GITHUB_OUTPUT"
63+
echo "repo=${GITHUB_REPOSITORY}" >> "$GITHUB_OUTPUT"
7664
7765
# Safe checkout: base repo only, not the untrusted PR head.
7866
- name: Checkout target repo base

0 commit comments

Comments
 (0)