Switch out pr url lookup method with repos/repo/pulls + filter (#71)

This commit is contained in:
MalTeeez 2026-07-14 02:36:09 +02:00 committed by GitHub
parent 219d11877b
commit 8d2e9d2fcf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 6 deletions

View File

@ -34,10 +34,14 @@ jobs:
id: lookup id: lookup
env: env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }} # Not inlined below to prevent injection from branch names
run: | run: |
PR_URL=$(gh api \ PR_URL=$(gh api --method GET \
"repos/${{ github.repository }}/commits/${{ github.event.workflow_run.head_sha }}/pulls" \ "repos/${{ github.repository }}/pulls" \
--jq "[.[] | select(.head.sha == \"${{ github.event.workflow_run.head_sha }}\" and .state == \"open\")] | first | .html_url // empty") -f state=open \
-f head="${{ github.event.workflow_run.head_repository.owner.login }}:${HEAD_BRANCH}" \
-f base="${{ github.event.repository.default_branch }}" \
--jq "([.[] | select(.head.sha == \"${{ github.event.workflow_run.head_sha }}\")] | first | .html_url) // (first | .html_url) // empty")
if [ -z "$PR_URL" ]; then if [ -z "$PR_URL" ]; then
echo "Failed to find a PR url" echo "Failed to find a PR url"

View File

@ -23,10 +23,14 @@ jobs:
id: lookup id: lookup
env: env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }} # Not inlined below to prevent injection from branch names
run: | run: |
PR_URL=$(gh api \ PR_URL=$(gh api --method GET \
"repos/${{ github.repository }}/commits/${{ github.event.workflow_run.head_sha }}/pulls" \ "repos/${{ github.repository }}/pulls" \
--jq "[.[] | select(.head.sha == \"${{ github.event.workflow_run.head_sha }}\" and .state == \"open\")] | first | .html_url // empty") -f state=open \
-f head="${{ github.event.workflow_run.head_repository.owner.login }}:${HEAD_BRANCH}" \
-f base="${{ github.event.repository.default_branch }}" \
--jq "([.[] | select(.head.sha == \"${{ github.event.workflow_run.head_sha }}\")] | first | .html_url) // (first | .html_url) // empty")
if [ -z "$PR_URL" ]; then if [ -z "$PR_URL" ]; then
echo "Failed to find a PR url" echo "Failed to find a PR url"