r-lib / actions

GitHub Actions for the R community
Creative Commons Zero v1.0 Universal
963 stars 210 forks source link

Use pkgdown action with PR preview #865

Open hadley opened 3 months ago

hadley commented 3 months ago

By copying @gadenbuie's: https://github.com/rstudio/education-workflows/blob/main/examples/pkgdown.yaml

Itt provides a nice way to preview pull requests and builds up a directory structure for tags that we can later use for versioned sites.

gaborcsardi commented 2 months ago

I looked at that workflow, and it is a good idea, but it does not deal with concurrency at all, so I think builds will fail when other builds finished just before them.

We can use the ideas from there, but we primarily need a good way to deal with concurrency, and GHA is not helping at all.

This said, if you like that workflow, AFAICT you can use it as a drop-in replacement in your repos, just to see how it works in practice. I am going to do the same.

gadenbuie commented 2 months ago

but it does not deal with concurrency at all, so I think builds will fail when other builds finished just before them.

I mentioned this to Hadley that I hadn't resolved concurrency yet. IIRC pkgdown::deploy_to_branch() force pushes to the deploy branch, so the workflow doesn't fail but there could be conflicts if there are simultaneous runs. In practice, this works fine for low-traffic repos where I'm the sole maintainer.

I think concurrency can mostly be solved by pulling gh-pages and rebasing just before pushing, but that would require either changes to deploy_to_branch() or to the workflow. Pulling and rebasing will sometimes fail, in which case re-running the appropriate job should do the trick.

In general, commits from pull requests are orthogonal to other commits and a "latest wins" approach is fine. Ideally commits on main would always be run sequentially, but GHA doesn't help with that.

gaborcsardi commented 1 month ago

For the record, we could also use netlify or cloudflare pages for OOTB live PR previews, but they both have usage limits, 300 build minutes and 300 build minutes per month, respectively.

hadley commented 1 month ago

The other option would be to set up something with S3, where we just eat the (presumably small) cost of hosting. But that's likely to be a non-trivial amount of work.

gaborcsardi commented 1 month ago

Yeah, I think the simplest would be to brute-force the concurrency issue with a pull-apply-push-undo loop.