Skip to content

Commit 8718198

Browse files
committed
ci(mkdocs): Refine documentation workflow push conditions and simplify checkout
Restrict automatic documentation updates to non-main branches on push and same-repository pull requests, enhancing control and security.
1 parent 5cc0855 commit 8718198

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

.github/workflows/mkdocs.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,10 @@ jobs:
4040
-
4141
name: Checkout
4242
uses: actions/checkout@v6
43-
if: github.event_name == 'push'
44-
-
45-
name: Checkout
46-
uses: actions/checkout@v6
47-
if: github.event_name == 'pull_request'
43+
with:
44+
ref: ${{ github.head_ref || github.ref_name }}
45+
fetch-depth: 0
46+
token: ${{ github.token }}
4847
-
4948
name: Setup .NET SDK
5049
uses: actions/setup-dotnet@v5
@@ -69,4 +68,8 @@ jobs:
6968
git config user.email '[email protected]'
7069
git commit -m 'Docs changes' --allow-empty
7170
git push --force
72-
if: steps.status.outputs.has_changes == '1' && github.event_name == 'push'
71+
if: >
72+
steps.status.outputs.has_changes == '1' && (
73+
(github.event_name == 'push' && github.ref_name != 'main') ||
74+
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
75+
)

0 commit comments

Comments
 (0)