Adventures with giscus (easier) and GitHub Actions (harder)
Note: This post was originally written by Shannon Pileggi and copied here on December 21, 2021 - see the original post here for a potentially updated version.
I made two modifications to my distill website and the corresponding GitHub repository:
Added giscus commenting to my blog - this was fairly straightforward and completed within 1 to 2 hours.
Added GitHub actions to automatically update the repositoryās README
with blog stats - this took several attempts over the course of a few days.
Straightforward and completed within 1 to 2 hours.
Updating the commenting mechanism on my website from discus was something I had been meaning to do for a while, but held off on because you never know when a seemingly small change will take you down a rabbit hole.
I went for it, and thanks to Joelās awesome post Enable giscus in Distill it was a pretty quick and easy process. š
tonight i intended to update my #rstats blog from disqus to utterances, but then i found this great post by @joel_nitta about āØgiscusāØ! thanks, Joel! š
i hope the new giscus gets used - go ahead, pipe up!šhttps://t.co/Wx1j80TKVDā Shannon Pileggi (@PipingHotData) December 1, 2021
Several attempts over the course of a few days.
After the amazingly quick success of the giscus implementation, I was ready to tackle more! I thought a mini-project on my blog would be a nice entry point to learn GitHub Actions, and I decided to replicate Matt Drayās post Up-to-date blog stats in your README. Between intricacies with both the README
and the GitHub Action workflow yaml
, this happened:
how is figuring out #rstats github actions going, you ask? preeetttty well š pic.twitter.com/Boj7KvXCAi
ā Shannon Pileggi (@PipingHotData) December 3, 2021
I mean, sometimes you can skip reading documentation fully, make a few tweaks to your code, cross your fingers, and hope that everything works. GitHub Actions is probably not one of those things. š¬ Below are a few of the errors I suffered through to get this working; hopefully I can save you some of the pain!
Workflow #1 (error)
I needed to add {distill}
as an installed package in my workflow. š¤·
Workflow #2 (error)
I was lazy with my README and workflow and loaded tidvyerse
instead of the specific packages I needed, which didnāt go well. I tried to resolve this via the pak
route (see next error), which also didnāt go well, and ended up trimming back the dependencies to the essential ones.
Workflow #10 (error)
I tried a few different things to install packages in the workflow with pak
instead of install.packages
. I attempted to use r-lib/actions/setup-r-dependencies
, and I really should have read the documentation thoroughly. My blog repo is not a package and does not have DESCRIPTION
file. I tried to add a DESCRIPTION
file to coerce this, but really, this workflow setup is made for packages. I also attempted to review the source of the workflow and make some tweaks to achieve something similar outside of the package framework, but to no avail. My workflow currently uses install.packages()
. I could have tried r-lib/actions/setup-renv
instead, but I was tired. There are many errors in my workflow history that correspond to this experimentation.Workflow #30 (no error)
I thought I would get fancy and make the ggplot graphic interactive through {ggiraph}
with hover over and click effects. This didnāt error out, but it also didnāt work, which I should have anticipated, as the rendered file is a .md
and not a .Rmd
.
Workflow #26 (no error)
I had many workflows that didnāt error out, but also did not result in an updated README
. I actually had a lot of trouble getting the README
to work. Some things I learned include:
usethis::use_readme_rmd()
is designed for use with R packages, and again, didnāt work well on my blog repo.
devtools::build_rmd()
is designed for use with R packages, and again, didnāt work well on my blog repo.
After I ditched these and my README
still wasnāt rendering correctly, I really, truly thought I was going crazy. I finally found a solution on RStudio Community by updating rmarkdown::render("README.Rmd")
to rmarkdown::render("README.Rmd", "github_document")
in the YAML
of the GitHub Action workflow. I wonder if {distill} has some YAML
stuff going on that required the "github_document"
argument.
After much perseverance and persistence, I prevailed with my first GitHub Action. šŖ
Perhaps reading the documentation more closely or slowing down to think through things might have worked better for this situation. If you want to have a laugh or or want to feel better about your own struggling efforts, browse through my 34 commits or check out the corresponding GitHub Action history Dec 1 - 12, 2021. Despite the frustration, I remain grateful for these experiences as I learned a lot.
So what happened after these changes?
One unexpected side effect of using giscus is all of the automatic notifications I receive about the discussion. I get notifications for:
on my blog: all comments
on blogs by others:
replies to my comments
all comments subsequent to mine, by anyone, as we are now all engaged in the same GitHub discussion.
The last one was a bit surprising to me, but I like it for now!
Now that I am using GitHub Actions on the README
of my repository, I am no longer the only contributor to my repository! šÆ This means that when I open up my R project, I now need to remember to pull before I start working on my website.
In addition, despite my GitHub Actions working, I ran out of free time as shown in the workflow #39 error
. š¤¦ I guess I either need to figure out {pak}
out with GitHub Actions to hopefully speed things up, or experiment less to get my actions right.š
Thanks to:
Dan Sjoberg and Travis Gerke for talking me through some GitHub Action concepts!
Allison Horst for the amazing illustrations.
Joel Nitta for the giscus post.
Matt Dray for the readme github action post.
Christophe Dervieux for being a hero on RStudio Community.
If you see mistakes or want to suggest changes, please create an issue on the source repository.
Text and figures are licensed under Creative Commons Attribution CC BY 4.0. Source code is available at https://github.com/jhelvy/distillery, unless otherwise noted. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".
For attribution, please cite this work as
Pileggi (2021, Dec. 13). The Distillery: Modifying the GitHub repo containing my Distill website. Retrieved from https://distillery.rbind.io/posts/2021-12-13-modifying-the-github-repo-containing-my-distill-website/
BibTeX citation
@misc{pileggi2021modifying, author = {Pileggi, Shannon}, title = {The Distillery: Modifying the GitHub repo containing my Distill website}, url = {https://distillery.rbind.io/posts/2021-12-13-modifying-the-github-repo-containing-my-distill-website/}, year = {2021} }