Deploy previews with Netlifly

deploy tutorial netlify github

Collaborative {distill} website workflows

Shannon Pileggi
04-01-2021

Note: This post was originally written by Shannon Pileggi and was copied here on April 04, 2021 - see the original post here for a potentially updated version.

TL; DR

If you are deploying your {distill} website through Netlifly, you can enable deploy previews to create temporary urls to preview a branch.

Background

My usual website workflow so far has been to draft posts in my master branch with draft: true in the yaml, and then when I am ready to publish switch to draft: false and commit to my main/master branch. Recently, I’ve been inspired to try alternative workflows:

I’m also a huge convert to the church of making PRs to yourself. Start with an R Markdown project like a simple slide deck or a bookdown book, then get into the habit of every change is a branch + PR. Low cost, but teaches you a lot! pic.twitter.com/Ee3tuoS4Ef

— Alison Presmanes Hill (@apreshill) February 20, 2021

I also collaborated with someone on a blog post for the first time, and I learned that you can send links to preview branches! 🎉 For both solo and collaborative posts, this is my new workflow.

I did a quick search for existing guides, and I found that Garrick Aden‑Buie has a comprehensive 2019 blog post titled A Blogdown New Post Workflow with Github and Netlify. Some of the steps are specific to {blogdown}, so here is my {distill} take on it.

Netlifly settings

First, make sure you have deploy previews enabled on Netlifly. Login to Netlifly, go to your site, and then:

➡️ Site settings

➡️ Build & deploy

➡️ Deploy contexts

➡️ Deploy previews

➡️ Select Any pull request against your production branch / branch deploy branches Netlify will generate a deploy preview with a unique URL for each built pull request.

Screenshot of Netlifly settings with Deploy previews set to "Any pull request...".

Figure 1: Screenshot of Netlifly settings with Deploy previews set to “Any pull request…”.

Back in website development

  1. Create a branch for your website repository. I am naming my branch netlifly-deploy-branch, and in the R console submit:
usethis::pr_init("netlifly-deploy-branch")
  1. Create a post. In R console submit:
distill::create_post("Deploy previews with Netlifly")
  1. Draft post; set draft: false in the yaml.

  2. Knit post. Depending on what you are doing in your branch, you may also need to 🔨 Build Website.

  3. Commit everything. In terminal submit:

git add .
git commit -m "draft netlifly post"
  1. Push to GitHub. In R console submit:
usethis::pr_push()
  1. In GitHub, click “Create pull request”.

  2. Some automatic checks will run. Click on “Details” where it says “Deploy preview ready!”

Screenshot of checks run on GitHub pull request. Click on "Details" where it says "Deploy preview ready!" to open the preview url.

Figure 2: Screenshot of checks run on GitHub pull request. Click on “Details” where it says “Deploy preview ready!” to open the preview url.

This opens up a window in my browser with the url https://deploy-preview-3--flamboyant-mccarthy-854a9b.netlify.app/. Send this link to a friend for review!

  1. Edit draft, repeat steps 4-8.

  2. When ready to publish, back in GitHub click on “Merge pull request”.

Added April 3, 2020:

I’m new to this workflow and this post was written quickly - edits and suggestions are welcome!

Acknowledgements

Thanks, Alison Hill!🤗

Also, thanks for the additional recommendations, Maëlle Salmon!

Corrections

If you see mistakes or want to suggest changes, please create an issue on the source repository.

Reuse

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 ...".

Citation

For attribution, please cite this work as

Pileggi (2021, April 1). The Distillery: Deploy previews with Netlifly. Retrieved from https://distillery.rbind.io/posts/2021-04-01-deploy-previews-with-netlifly/

BibTeX citation

@misc{pileggi2021deploy,
  author = {Pileggi, Shannon},
  title = {The Distillery: Deploy previews with Netlifly},
  url = {https://distillery.rbind.io/posts/2021-04-01-deploy-previews-with-netlifly/},
  year = {2021}
}