For some reasons (and mostly because distill is much easier in my opinion), I switched to distill. The second one is more tricky, but could be useful for several people. Some will be essential for everyone (e.g distill) but other packages won’t be (e.g postcards). The first one is that I need to install more packages to render my distill website. yml file, there are two main differences. To automatically render your distill website on every push on master branch, the logic is very similar. On : push : branches : master schedule : - cron : '0 0 * * MON' name : Render README jobs : render : name : Render README runs-on : macOS-latest steps : - uses : - uses : - uses : - name : Install rmarkdown run : Rscript -e 'install.packages("rmarkdown")' - name : Render README run : Rscript -e 'rmarkdown::render("README.Rmd", output_format = "md_document")' - name : Commit results run : | git commit README.md -m 'Re-build README.Rmd' || echo "No changes to commit" git push origin || echo "No changes to commit" Render a Distill website See the documentation to know how to format your schedule. Hence, I use cron to run GitHub Actions every Monday at 00:00. Actually, for my list of JavaScript libraries to be up-to-date, I also need to scrape the htmlwidgets gallery once in a while. yaml file I use on my repo, but I lied a bit. Now, every time I change the CSV file on the master branch, the README will be automatically rendered (after a few minutes, since all the actions have to run first). Hence, the last step is to commit the changes with a message and to push them on the master branch. Last but not least, GitHub Actions rendered the README, but the changes are not on the repo yet. There are some parts that I just copied and pasted from the R actions repository, but basically you can see that first it initiates R and pandoc ( Then, I run an R script to install the rmarkdown package and I use it to render the Rmd file to create README.md. The name of this process is “Render README”. The jobs run every time there’s a push on the master branch The first two parts are quite self-explanatory: On : push : branches : master name : Render README jobs : render : name : Render README runs-on : macOS-latest steps : - uses : - uses : - uses : - name : Install rmarkdown run : Rscript -e 'install.packages("rmarkdown")' - name : Render README run : Rscript -e 'rmarkdown::render("README.Rmd", output_format = "md_document")' - name : Commit results run : | git commit README.md -m 'Re-build README.Rmd' || echo "No changes to commit" git push origin || echo "No changes to commit" yml file that contains the R code you want to run to render the README. This is where GitHub Actions comes into play. Without GitHub Actions, in addition to modify the CSV file, I would have to clone the repo, open it in RStudio, render the README, and push it back on GitHub.īut this task is repetitive: apart from the details I add to the CSV file, it can be automated. The problem is that this CSV file is then used into an R Markdown file, that creates a clean README with all the information. The idea is that when I (or someone else) find a JavaScript library that has been adapted into an R package, I add it to a CSV file on GitHub. I wanted this list to be easy to update, so that it can be done on GitHub directly. One of my GitHub repos is a list of JavaScript libraries that have been adapted in R. In this post, I will present you two cases in which I use GitHub Actions to automatically do that. Sometimes, it is useful to automatically render an R Markdown document or a website, made with distill for example.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |