mirror of
https://github.com/esphome/esphome.git
synced 2025-10-25 13:13:48 +01:00
[ci] Fix fork PR workflow failing to find PRs from forks (#11396)
This commit is contained in:
19
.github/workflows/ci-memory-impact-comment.yml
vendored
19
.github/workflows/ci-memory-impact-comment.yml
vendored
@@ -28,20 +28,23 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
# Get PR details by searching for PR with matching head SHA
|
# Get PR details by searching for PR with matching head SHA
|
||||||
# The workflow_run.pull_requests field is often empty for forks
|
# The workflow_run.pull_requests field is often empty for forks
|
||||||
|
# Use paginate to handle repos with many open PRs
|
||||||
head_sha="${{ github.event.workflow_run.head_sha }}"
|
head_sha="${{ github.event.workflow_run.head_sha }}"
|
||||||
pr_data=$(gh api "/repos/${{ github.repository }}/commits/$head_sha/pulls" \
|
pr_data=$(gh api --paginate "/repos/${{ github.repository }}/pulls" \
|
||||||
--jq '.[0] | {number: .number, base_ref: .base.ref}')
|
--jq ".[] | select(.head.sha == \"$head_sha\") | {number: .number, base_ref: .base.ref}" \
|
||||||
if [ -z "$pr_data" ] || [ "$pr_data" == "null" ]; then
|
| head -n 1)
|
||||||
|
|
||||||
|
if [ -z "$pr_data" ]; then
|
||||||
echo "No PR found for SHA $head_sha, skipping"
|
echo "No PR found for SHA $head_sha, skipping"
|
||||||
echo "skip=true" >> $GITHUB_OUTPUT
|
echo "skip=true" >> "$GITHUB_OUTPUT"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pr_number=$(echo "$pr_data" | jq -r '.number')
|
pr_number=$(echo "$pr_data" | jq -r '.number')
|
||||||
base_ref=$(echo "$pr_data" | jq -r '.base_ref')
|
base_ref=$(echo "$pr_data" | jq -r '.base_ref')
|
||||||
|
|
||||||
echo "pr_number=$pr_number" >> $GITHUB_OUTPUT
|
echo "pr_number=$pr_number" >> "$GITHUB_OUTPUT"
|
||||||
echo "base_ref=$base_ref" >> $GITHUB_OUTPUT
|
echo "base_ref=$base_ref" >> "$GITHUB_OUTPUT"
|
||||||
echo "Found PR #$pr_number targeting base branch: $base_ref"
|
echo "Found PR #$pr_number targeting base branch: $base_ref"
|
||||||
|
|
||||||
- name: Check out code from base repository
|
- name: Check out code from base repository
|
||||||
@@ -87,9 +90,9 @@ jobs:
|
|||||||
if: steps.pr.outputs.skip != 'true'
|
if: steps.pr.outputs.skip != 'true'
|
||||||
run: |
|
run: |
|
||||||
if [ -f ./memory-analysis/memory-analysis-target.json ] && [ -f ./memory-analysis/memory-analysis-pr.json ]; then
|
if [ -f ./memory-analysis/memory-analysis-target.json ] && [ -f ./memory-analysis/memory-analysis-pr.json ]; then
|
||||||
echo "found=true" >> $GITHUB_OUTPUT
|
echo "found=true" >> "$GITHUB_OUTPUT"
|
||||||
else
|
else
|
||||||
echo "found=false" >> $GITHUB_OUTPUT
|
echo "found=false" >> "$GITHUB_OUTPUT"
|
||||||
echo "Memory analysis artifacts not found, skipping comment"
|
echo "Memory analysis artifacts not found, skipping comment"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user