Skip to content

Commit 19a6297

Browse files
committed
Add mention in the doc on supporting pull_request/closed
1 parent 717fea2 commit 19a6297

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,35 @@ the `push` events instead. This is most likely only useful for setups not
391391
accepting external PRs and you will not have the best user experience.
392392
If that's something you need to do, please have a look at [this issue](https://github.com/py-cov-action/python-coverage-comment-action/issues/234).
393393

394+
### Updating the coverage information on the `pull_request/closed` event
395+
396+
Usually, the coverage data for the repository is updated on `push` events to the default
397+
branch, but it can also work to do it on `pull_request/closed` events, especially if
398+
you require all changes to go through a pull request.
399+
400+
In this case, your workflow's `on:` clause should look like this:
401+
402+
```yaml
403+
on:
404+
pull_request:
405+
# opened, synchronize, reopened are the default value
406+
# closed will trigger when the PR is closed (merged or not)
407+
types: [opened, synchronize, reopened, closed]
408+
409+
jobs:
410+
build:
411+
# Optional: if you want to avoid doing the whole build on PRs closed without
412+
# merging, add the following clause. Note that this action won't update the
413+
# coverage data even if you don't specify this (it will raise an error instead),
414+
# but it can help you avoid a useless build.
415+
if: github.event.action != "closed" || github.event.pull_request.merged == true
416+
runs-on: ubuntu-latest
417+
...
418+
```
419+
420+
> [!TIP]
421+
> The action will also save repository coverage data on `schedule` workflows.
422+
394423
## Overriding the template
395424

396425
By default, comments are generated from a

0 commit comments

Comments
 (0)