Skip to content

Commit 590e568

Browse files
authored
fix: handle fork PRs in readme and cli-docs workflows (#2707)
1 parent e52e1e0 commit 590e568

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

.github/workflows/cli-docs.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,16 @@ jobs:
4343
github.event.sender.login == 'ilovelinux'))
4444
runs-on: ubuntu-latest
4545
steps:
46+
# Checkout for forks (no PAT available)
4647
- uses: actions/checkout@v4
48+
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository
49+
with:
50+
fetch-depth: 0
51+
ref: ${{ github.event.pull_request.head.ref }}
52+
repository: ${{ github.event.pull_request.head.repo.full_name }}
53+
# Checkout for same-repo PRs, pushes, and pull_request_target
54+
- uses: actions/checkout@v4
55+
if: github.event_name == 'push' || github.event_name == 'pull_request_target' || github.event.pull_request.head.repo.full_name == github.repository
4756
with:
4857
fetch-depth: 0
4958
ref: ${{ github.event.pull_request.head.ref || github.ref }}
@@ -62,6 +71,7 @@ jobs:
6271
- name: Build CLI docs
6372
run: .tox/cli-docs/bin/python scripts/build_cli_docs.py
6473
- name: Commit and push if changed
74+
if: github.event_name == 'push' || github.event_name == 'pull_request_target' || github.event.pull_request.head.repo.full_name == github.repository
6575
run: |
6676
git config user.name "github-actions[bot]"
6777
git config user.email "github-actions[bot]@users.noreply.github.com"

.github/workflows/readme.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,16 @@ jobs:
3131
github.event.sender.login == 'ilovelinux'))
3232
runs-on: ubuntu-latest
3333
steps:
34+
# Checkout for forks (no PAT available)
3435
- uses: actions/checkout@v4
36+
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository
37+
with:
38+
fetch-depth: 0
39+
ref: ${{ github.event.pull_request.head.ref }}
40+
repository: ${{ github.event.pull_request.head.repo.full_name }}
41+
# Checkout for same-repo PRs, pushes, and pull_request_target
42+
- uses: actions/checkout@v4
43+
if: github.event_name == 'push' || github.event_name == 'pull_request_target' || github.event.pull_request.head.repo.full_name == github.repository
3544
with:
3645
fetch-depth: 0
3746
ref: ${{ github.event.pull_request.head.ref || github.ref }}
@@ -48,6 +57,7 @@ jobs:
4857
- name: Update README
4958
run: .tox/readme/bin/python scripts/update_command_help_on_markdown.py
5059
- name: Commit and push if changed
60+
if: github.event_name == 'push' || github.event_name == 'pull_request_target' || github.event.pull_request.head.repo.full_name == github.repository
5161
run: |
5262
git config user.name "github-actions[bot]"
5363
git config user.email "github-actions[bot]@users.noreply.github.com"

0 commit comments

Comments
 (0)