Stop concurrent JavaDoc runs racing to push gh-pages - #123
Merged
Conversation
Every run of this workflow publishes to the same gh-pages branch. When two are in flight together they race to update the ref and the loser is rejected with "cannot lock ref 'refs/heads/gh-pages'", which is why a re-run then succeeds: by that point the other run has finished. Concurrent runs are routine rather than exceptional here, because a release pushes several commits to main within a few seconds and each one triggers this workflow. Four overlapping runs on 2026-07-18 (06:55:00, :04, :11 and :18, each around 30 seconds long) and four more on 2026-06-13 are visible in the run history. Add a concurrency group so the runs queue instead of overlapping. Queue rather than cancel, so a publish that has already started is not interrupted part way. The group leaves the ref out on purpose: the branch being written to is gh-pages no matter which ref triggered the run. Fixes spdx#85 Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
bact
approved these changes
Aug 28, 2026
Contributor
Author
|
@bact please merge when you can. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #85.
I do not think this is GitHub being flaky. The error is specifically a ref-lock rejection:
That is what git says when the branch moved between the pushing run's fetch and its push, i.e. something else pushed
gh-pagesin between. The only thing that pushesgh-pageshere is this workflow, and it triggers on every push tomain.During a release, several commits land on
mainwithin seconds, so several docs runs are in flight at once and each one wants to publish. That is visible in the run history rather than being hypothetical. On 2026-07-18 four runs started at 06:55:00, 06:55:04, 06:55:11 and 06:55:18, each taking roughly 30 seconds, so all four overlapped:The same shape appears on 2026-06-13 (four runs across 16:51:42 to 16:53:14) and 2026-06-28. It also explains "if the job is re-run, it tends to succeed": by then the other runs are done and there is nothing to race with.
Adding a concurrency group makes the runs queue instead of overlapping, so only one publish touches
gh-pagesat a time.Two deliberate choices in it:
cancel-in-progress: false, so a publish that has already started is allowed to finish rather than being cancelled part way through pushing.${{ github.workflow }}withoutgithub.ref. The output branch isgh-pagesregardless of which ref triggered the run, so including the ref would let aworkflow_dispatchfrom another ref race with amainpush, which is the thing being fixed.One caveat worth stating: I could not reproduce the failure, and the current run history shows no failed runs, because a re-run replaces the conclusion of the run it re-runs. So this rests on the error message and the overlapping timings above rather than on a red run I can point you at.
If this looks right, the same workflow appears in other
spdx-java-*repositories and would have the same exposure. Happy to open the matching PRs, but I did not want to send a batch before this one is agreed.