From 2273b26a7bad912ef6209f5744a880acb4cc4541 Mon Sep 17 00:00:00 2001 From: hudeng Date: Tue, 21 Jul 2026 11:23:14 +0800 Subject: [PATCH] fix: add repository parameter to checkout steps for fork PR compatibility When using pull_request_target trigger, the checkout step needs to explicitly specify the repository to check out from the fork repo. Otherwise, PRs from forks fail at checkout because the head SHA doesn't exist in the base repository. Also upgrade actions/checkout from v5 to v7. --- .github/workflows/auto-tag.yml | 3 ++- .github/workflows/build-distribution.yml | 20 ++++++++++++-------- .github/workflows/commitlint.yml | 3 ++- .github/workflows/doc-check.yml | 3 ++- .github/workflows/dtk-unittest.yml | 5 +++-- .github/workflows/license-check.yml | 9 ++++++--- 6 files changed, 27 insertions(+), 16 deletions(-) diff --git a/.github/workflows/auto-tag.yml b/.github/workflows/auto-tag.yml index 2faddc256..f9aca5a9f 100644 --- a/.github/workflows/auto-tag.yml +++ b/.github/workflows/auto-tag.yml @@ -16,9 +16,10 @@ jobs: auto_tag: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v7 with: ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} persist-credentials: false - name: get changelog version id: get-version diff --git a/.github/workflows/build-distribution.yml b/.github/workflows/build-distribution.yml index d06b7312c..bfac0e866 100644 --- a/.github/workflows/build-distribution.yml +++ b/.github/workflows/build-distribution.yml @@ -22,11 +22,12 @@ jobs: outputs: result: ${{ steps.result.outputs.RESULT }} steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v7 if: ${{ github.event.pull_request.head.sha }} with: ref: ${{ github.event.pull_request.head.sha }} - - uses: actions/checkout@v5 + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/checkout@v7 if: ${{ github.event_name == 'push' }} with: fetch-depth: 0 @@ -62,11 +63,12 @@ jobs: ssh-private-key: ${{ secrets.BUILD_SSH_PRIVATE_KEY }} - run: git config --global user.email "ci@deepin.org" - run: git config --global user.name "deepin-ci" - - uses: actions/checkout@v5 + - uses: actions/checkout@v7 if: ${{ github.event.pull_request.head.sha }} with: ref: ${{ github.event.pull_request.head.sha }} - - uses: actions/checkout@v5 + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/checkout@v7 if: ${{ github.event_name == 'push' }} with: fetch-depth: 0 @@ -157,11 +159,12 @@ jobs: needs: [debian-setup] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v7 if: ${{ github.event.pull_request.head.sha }} with: ref: ${{ github.event.pull_request.head.sha }} - - uses: actions/checkout@v5 + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/checkout@v7 if: ${{ github.event_name == 'push' }} with: fetch-depth: 0 @@ -361,11 +364,12 @@ jobs: continue-on-error: true runs-on: ubuntu-latest steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v7 if: ${{ github.event.pull_request.head.sha }} with: ref: ${{ github.event.pull_request.head.sha }} - - uses: actions/checkout@v5 + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/checkout@v7 if: ${{ github.event_name == 'push' }} with: fetch-depth: 0 diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml index fc1e8cec0..0391162e7 100644 --- a/.github/workflows/commitlint.yml +++ b/.github/workflows/commitlint.yml @@ -7,9 +7,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Fetch code - uses: actions/checkout@v5 + uses: actions/checkout@v7 with: ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} fetch-depth: 0 - name: check PR description for AI co-author pattern diff --git a/.github/workflows/doc-check.yml b/.github/workflows/doc-check.yml index c5365dbe4..293d78418 100644 --- a/.github/workflows/doc-check.yml +++ b/.github/workflows/doc-check.yml @@ -57,9 +57,10 @@ jobs: echo "Init failed after $retries attempts. Giving up." exit 1 - - uses: actions/checkout@v5 + - uses: actions/checkout@v7 with: ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} persist-credentials: false - uses: linuxdeepin/action-doxygencheck@master diff --git a/.github/workflows/dtk-unittest.yml b/.github/workflows/dtk-unittest.yml index 45e04ce72..736089984 100644 --- a/.github/workflows/dtk-unittest.yml +++ b/.github/workflows/dtk-unittest.yml @@ -20,11 +20,12 @@ jobs: - /sys/fs/cgroup:/sys/fs/cgroup - /etc/machine-id:/etc/machine-id steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v7 if: ${{ github.event.pull_request.head.sha }} with: ref: ${{ github.event.pull_request.head.sha }} - - uses: actions/checkout@v5 + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/checkout@v7 if: ${{ github.event_name == 'push' }} - name: Install Dependences diff --git a/.github/workflows/license-check.yml b/.github/workflows/license-check.yml index dd0cff574..6c6c33433 100644 --- a/.github/workflows/license-check.yml +++ b/.github/workflows/license-check.yml @@ -5,11 +5,12 @@ jobs: Check-License: runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v7 with: # fetch-depth: 0 必不可少,否则 git diff 找不到对比基准 fetch-depth: 0 ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} - name: Setup Python id: python @@ -113,9 +114,10 @@ jobs: Check-README: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v7 with: ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} - name: Install zsh run: | sudo sed -i 's/azure.archive.ubuntu.com/mirrors.layeronline.com/g' /etc/apt/sources.list @@ -143,10 +145,11 @@ jobs: Check-SPDX-Copyright: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v7 with: fetch-depth: 0 ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} - uses: zccrs/github-actions-spdx-checker@main with: include: '*.py,*.js,*.jsx,*.tsx,*.java,*.cpp,*.c,*.h,*.hpp,*.go,*.rs,*.rb,*.php,*.sh,*.xml,*.yaml,*.yml,*.qml,CMakeLists.txt,Makefile'