From 9243fb369412987337d75671a6c7bde6abf199a2 Mon Sep 17 00:00:00 2001 From: Tony Date: Tue, 14 Apr 2026 20:52:51 +0800 Subject: [PATCH] chore: fix find PR no. by branch name for dependabot --- .github/workflows/docker-test-cont.yml | 18 ++++-------------- .github/workflows/pr-review.yml | 8 ++------ 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/.github/workflows/docker-test-cont.yml b/.github/workflows/docker-test-cont.yml index ded0e39d8..cf21c04ee 100644 --- a/.github/workflows/docker-test-cont.yml +++ b/.github/workflows/docker-test-cont.yml @@ -23,13 +23,8 @@ jobs: GH_TOKEN: ${{ github.token }} # Best practice for scripts is to reference via ENV at runtime. Avoid using the expression syntax in the script content directly: PR_TARGET_REPO: ${{ github.repository }} - # If the PR is from a fork, prefix it with `:`, otherwise only the PR branch name is relevant: - PR_BRANCH: |- - ${{ - (github.event.workflow_run.head_repository.owner.login != github.event.workflow_run.repository.owner.login) - && format('{0}:{1}', github.event.workflow_run.head_repository.owner.login, github.event.workflow_run.head_branch) - || github.event.workflow_run.head_branch - }} + # The REST API `head` filter requires `:` format + PR_BRANCH: ${{ format('{0}:{1}', github.event.workflow_run.head_repository.owner.login, github.event.workflow_run.head_branch) }} # Query the PR number by repo + branch, then assign to step output: run: | gh api "repos/${PR_TARGET_REPO}/pulls" \ @@ -172,13 +167,8 @@ jobs: GH_TOKEN: ${{ github.token }} # Best practice for scripts is to reference via ENV at runtime. Avoid using the expression syntax in the script content directly: PR_TARGET_REPO: ${{ github.repository }} - # If the PR is from a fork, prefix it with `:`, otherwise only the PR branch name is relevant: - PR_BRANCH: |- - ${{ - (github.event.workflow_run.head_repository.owner.login != github.event.workflow_run.repository.owner.login) - && format('{0}:{1}', github.event.workflow_run.head_repository.owner.login, github.event.workflow_run.head_branch) - || github.event.workflow_run.head_branch - }} + # The REST API `head` filter requires `:` format + PR_BRANCH: ${{ format('{0}:{1}', github.event.workflow_run.head_repository.owner.login, github.event.workflow_run.head_branch) }} # Query the PR number by repo + branch, then assign to step output: run: | gh api "repos/${PR_TARGET_REPO}/pulls" \ diff --git a/.github/workflows/pr-review.yml b/.github/workflows/pr-review.yml index 57fd48e25..213d6f9f9 100644 --- a/.github/workflows/pr-review.yml +++ b/.github/workflows/pr-review.yml @@ -31,12 +31,8 @@ jobs: env: GH_TOKEN: ${{ github.token }} PR_TARGET_REPO: ${{ github.repository }} - PR_BRANCH: |- - ${{ - (github.event.workflow_run.head_repository.owner.login != github.event.workflow_run.repository.owner.login) - && format('{0}:{1}', github.event.workflow_run.head_repository.owner.login, github.event.workflow_run.head_branch) - || github.event.workflow_run.head_branch - }} + # The REST API `head` filter requires `:` format + PR_BRANCH: ${{ format('{0}:{1}', github.event.workflow_run.head_repository.owner.login, github.event.workflow_run.head_branch) }} run: | gh api "repos/${PR_TARGET_REPO}/pulls" \ --method GET -f head="${PR_BRANCH}" -f state=open \