Skip to content

Commit 217d12b

Browse files
committed
Fix gh-pages deploy race condition
Replace pull_request_target with pull_request to prevent duplicate workflow runs when merging PRs to master. Previously, merging a PR fired both 'push' and 'pull_request_target' simultaneously, causing two runs to race for the gh-pages force-push. The loser failed with a "cannot lock ref" error. With pull_request, only the push event deploys on merge, while PRs still get build-tested.
1 parent bdc67a3 commit 217d12b

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

.github/workflows/python_sphinx_docs.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@ on:
44
push:
55
branches:
66
- '**'
7-
pull_request_target:
8-
types: closed
9-
branches: master
7+
# Use pull_request (not pull_request_target) to build-test docs on PRs targeting master.
8+
# When a PR is merged, only the 'push' event triggers deployment to gh-pages.
9+
# Using pull_request_target here previously caused a race condition: merging a PR fired
10+
# both 'push' and 'pull_request_target' simultaneously, producing two concurrent runs
11+
# that both tried to force-push to gh-pages. The loser would fail with:
12+
# "cannot lock ref 'refs/heads/gh-pages': is at <new-sha> but expected <old-sha>"
13+
# See: https://github.com/OPM/opm-python-documentation/actions/runs/21938360885
14+
pull_request:
15+
branches: [master]
1016
repository_dispatch:
1117
types: [docstrings_common_updated, docstrings_simulators_updated]
1218
permissions:

0 commit comments

Comments
 (0)