Skip to content

Commit 10499fb

Browse files
hudeng-goBLumia
authored andcommitted
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.
1 parent 126af43 commit 10499fb

6 files changed

Lines changed: 27 additions & 16 deletions

File tree

.github/workflows/auto-tag.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ jobs:
1616
auto_tag:
1717
runs-on: ubuntu-latest
1818
steps:
19-
- uses: actions/checkout@v5
19+
- uses: actions/checkout@v7
2020
with:
2121
ref: ${{ github.event.pull_request.head.sha }}
22+
repository: ${{ github.event.pull_request.head.repo.full_name }}
2223
persist-credentials: false
2324
- name: get changelog version
2425
id: get-version

.github/workflows/build-distribution.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ jobs:
2222
outputs:
2323
result: ${{ steps.result.outputs.RESULT }}
2424
steps:
25-
- uses: actions/checkout@v5
25+
- uses: actions/checkout@v7
2626
if: ${{ github.event.pull_request.head.sha }}
2727
with:
2828
ref: ${{ github.event.pull_request.head.sha }}
29-
- uses: actions/checkout@v5
29+
repository: ${{ github.event.pull_request.head.repo.full_name }}
30+
- uses: actions/checkout@v7
3031
if: ${{ github.event_name == 'push' }}
3132
with:
3233
fetch-depth: 0
@@ -62,11 +63,12 @@ jobs:
6263
ssh-private-key: ${{ secrets.BUILD_SSH_PRIVATE_KEY }}
6364
- run: git config --global user.email "ci@deepin.org"
6465
- run: git config --global user.name "deepin-ci"
65-
- uses: actions/checkout@v5
66+
- uses: actions/checkout@v7
6667
if: ${{ github.event.pull_request.head.sha }}
6768
with:
6869
ref: ${{ github.event.pull_request.head.sha }}
69-
- uses: actions/checkout@v5
70+
repository: ${{ github.event.pull_request.head.repo.full_name }}
71+
- uses: actions/checkout@v7
7072
if: ${{ github.event_name == 'push' }}
7173
with:
7274
fetch-depth: 0
@@ -157,11 +159,12 @@ jobs:
157159
needs: [debian-setup]
158160
runs-on: ubuntu-latest
159161
steps:
160-
- uses: actions/checkout@v5
162+
- uses: actions/checkout@v7
161163
if: ${{ github.event.pull_request.head.sha }}
162164
with:
163165
ref: ${{ github.event.pull_request.head.sha }}
164-
- uses: actions/checkout@v5
166+
repository: ${{ github.event.pull_request.head.repo.full_name }}
167+
- uses: actions/checkout@v7
165168
if: ${{ github.event_name == 'push' }}
166169
with:
167170
fetch-depth: 0
@@ -361,11 +364,12 @@ jobs:
361364
continue-on-error: true
362365
runs-on: ubuntu-latest
363366
steps:
364-
- uses: actions/checkout@v5
367+
- uses: actions/checkout@v7
365368
if: ${{ github.event.pull_request.head.sha }}
366369
with:
367370
ref: ${{ github.event.pull_request.head.sha }}
368-
- uses: actions/checkout@v5
371+
repository: ${{ github.event.pull_request.head.repo.full_name }}
372+
- uses: actions/checkout@v7
369373
if: ${{ github.event_name == 'push' }}
370374
with:
371375
fetch-depth: 0

.github/workflows/commitlint.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- name: Fetch code
10-
uses: actions/checkout@v5
10+
uses: actions/checkout@v7
1111
with:
1212
ref: ${{ github.event.pull_request.head.sha }}
13+
repository: ${{ github.event.pull_request.head.repo.full_name }}
1314
fetch-depth: 0
1415

1516
- name: check PR description for AI co-author pattern

.github/workflows/doc-check.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@ jobs:
5757
echo "Init failed after $retries attempts. Giving up."
5858
exit 1
5959
60-
- uses: actions/checkout@v5
60+
- uses: actions/checkout@v7
6161
with:
6262
ref: ${{ github.event.pull_request.head.sha }}
63+
repository: ${{ github.event.pull_request.head.repo.full_name }}
6364
persist-credentials: false
6465

6566
- uses: linuxdeepin/action-doxygencheck@master

.github/workflows/dtk-unittest.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ jobs:
2020
- /sys/fs/cgroup:/sys/fs/cgroup
2121
- /etc/machine-id:/etc/machine-id
2222
steps:
23-
- uses: actions/checkout@v5
23+
- uses: actions/checkout@v7
2424
if: ${{ github.event.pull_request.head.sha }}
2525
with:
2626
ref: ${{ github.event.pull_request.head.sha }}
27-
- uses: actions/checkout@v5
27+
repository: ${{ github.event.pull_request.head.repo.full_name }}
28+
- uses: actions/checkout@v7
2829
if: ${{ github.event_name == 'push' }}
2930

3031
- name: Install Dependences

.github/workflows/license-check.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ jobs:
55
Check-License:
66
runs-on: ubuntu-24.04
77
steps:
8-
- uses: actions/checkout@v5
8+
- uses: actions/checkout@v7
99
with:
1010
# fetch-depth: 0 必不可少,否则 git diff 找不到对比基准
1111
fetch-depth: 0
1212
ref: ${{ github.event.pull_request.head.sha }}
13+
repository: ${{ github.event.pull_request.head.repo.full_name }}
1314

1415
- name: Setup Python
1516
id: python
@@ -113,9 +114,10 @@ jobs:
113114
Check-README:
114115
runs-on: ubuntu-latest
115116
steps:
116-
- uses: actions/checkout@v5
117+
- uses: actions/checkout@v7
117118
with:
118119
ref: ${{ github.event.pull_request.head.sha }}
120+
repository: ${{ github.event.pull_request.head.repo.full_name }}
119121
- name: Install zsh
120122
run: |
121123
sudo sed -i 's/azure.archive.ubuntu.com/mirrors.layeronline.com/g' /etc/apt/sources.list
@@ -143,10 +145,11 @@ jobs:
143145
Check-SPDX-Copyright:
144146
runs-on: ubuntu-latest
145147
steps:
146-
- uses: actions/checkout@v5
148+
- uses: actions/checkout@v7
147149
with:
148150
fetch-depth: 0
149151
ref: ${{ github.event.pull_request.head.sha }}
152+
repository: ${{ github.event.pull_request.head.repo.full_name }}
150153
- uses: zccrs/github-actions-spdx-checker@main
151154
with:
152155
include: '*.py,*.js,*.jsx,*.tsx,*.java,*.cpp,*.c,*.h,*.hpp,*.go,*.rs,*.rb,*.php,*.sh,*.xml,*.yaml,*.yml,*.qml,CMakeLists.txt,Makefile'

0 commit comments

Comments
 (0)