From c0a2b11e2958c3c7557202ecbbee153539902a1f Mon Sep 17 00:00:00 2001 From: dcvz Date: Thu, 1 Aug 2024 11:24:02 +0200 Subject: [PATCH] find PR that matches the upstream --- .github/workflows/update-pr-artifacts.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/update-pr-artifacts.yml b/.github/workflows/update-pr-artifacts.yml index 9b4299b..2a51c36 100644 --- a/.github/workflows/update-pr-artifacts.yml +++ b/.github/workflows/update-pr-artifacts.yml @@ -15,10 +15,13 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - pr_number=$(gh api \ - -H "Accept: application/vnd.github+json" \ - /repos/${{ github.event.pull_request.head.repo.full_name }}/commits/${{ github.event.workflow_run.head_sha }}/pulls \ - --jq '.[0].number') + # Get list of PR's associated to the commit that triggered the workflow run + prs=$(gh api \ + -H "Accept: application/vnd.github+json" \ + /repos/${{ github.event.pull_request.head.repo.full_name }}/commits/${{ github.event.workflow_run.head_sha }}/pulls) + + # Find the PR against the current repo + pr_number=$(echo "$prs" | jq -r '.[] | select(.base.repo.full_name == "${{ github.repository }}") | .number' | head -n1) if [ -z "$pr_number" ]; then echo "No pull request found for this workflow run"