<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Nikola (Posts about GitHub Actions)</title><link>https://getnikola.com/</link><description></description><atom:link href="https://getnikola.com/categories/github-actions.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><lastBuildDate>Sat, 17 May 2025 17:58:54 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Automating Nikola rebuilds with GitHub Actions</title><link>https://getnikola.com/blog/automating-nikola-rebuilds-with-github-actions.html</link><dc:creator>Chris Warrick</dc:creator><description>&lt;p&gt;In this guide, we’ll set up GitHub Actions to rebuild a &lt;a class="reference external" href="https://getnikola.com/"&gt;Nikola&lt;/a&gt; website and host it on GitHub Pages.&lt;/p&gt;
&lt;section id="why"&gt;
&lt;h2&gt;Why?&lt;/h2&gt;
&lt;p&gt;By using GitHub Actions to build your site, you can easily blog from anywhere
you can edit text files. Which means you can blog with only a web
browser and &lt;a class="reference external" href="https://github.com"&gt;GitHub.com&lt;/a&gt;.
You also won’t need to install Nikola and Python to write. You won’t need a
real computer either — a mobile phone could probably access GitHub.com and write something.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="caveats"&gt;
&lt;h2&gt;Caveats&lt;/h2&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;p&gt;The build might take a couple minutes to finish (1:30 for the demo site;
YMMV)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When you commit and push to GitHub, the site will be published
unconditionally. If you don’t have a copy of Nikola for local use, there is
no way to preview your site.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/section&gt;
&lt;section id="what-you-need"&gt;
&lt;h2&gt;What you need&lt;/h2&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;p&gt;A computer for the initial setup that can run Nikola. You can do it with any
OS (Linux, macOS, *BSD, but also Windows).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A GitHub account (free)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/section&gt;
&lt;section id="setting-up-nikola"&gt;
&lt;h2&gt;Setting up Nikola&lt;/h2&gt;
&lt;p&gt;Start by creating a new Nikola site and customizing it to your liking. Follow
the &lt;a class="reference external" href="https://getnikola.com/getting-started.html"&gt;Getting Started guide&lt;/a&gt;. You
might also want to add support for &lt;a class="reference external" href="https://getnikola.com/handbook.html#configuring-other-input-formats"&gt;other input formats&lt;/a&gt;, namely
Markdown, but this is not a requirement.&lt;/p&gt;
&lt;p&gt;After you’re done, you must configure &lt;a class="reference external" href="https://getnikola.com/handbook.html#deploying-to-github"&gt;deploying to GitHub&lt;/a&gt; in Nikola. There
are a few important things you need to take care of:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;p&gt;Make your first deployment from your local computer and make sure your site
works right. Don’t forget to set up &lt;code class="docutils literal"&gt;.gitignore&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;code class="docutils literal"&gt;GITHUB_COMMIT_SOURCE&lt;/code&gt; and &lt;code class="docutils literal"&gt;GITHUB_REMOTE_NAME&lt;/code&gt; settings are
overridden, so you can use values appropriate for your local builds.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ensure that the correct branch for GitHub Pages is set on GitHub.com.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If everything works, you can make some change to your site (so you see that
rebuilding works), but don’t commit it just yet.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="setting-up-github-actions"&gt;
&lt;h2&gt;Setting up GitHub Actions&lt;/h2&gt;
&lt;p&gt;Next, we need to set up GitHub Actions. This is really straightforward.&lt;/p&gt;
&lt;p&gt;On your source branch, create a file named &lt;code class="docutils literal"&gt;.github/workflows/main.yml&lt;/code&gt; with the following contents:&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="https://getnikola.com/listings/github-workflow.yml.html"&gt;github-workflow.yml&lt;/a&gt;  &lt;a class="reference external" href="https://getnikola.com/listings/github-workflow.yml"&gt;(Source)&lt;/a&gt;&lt;/p&gt;
&lt;div class="code"&gt;&lt;table class="codetable"&gt;&lt;tr&gt;&lt;td class="linenos linenodiv"&gt;&lt;a href="https://getnikola.com/blog/automating-nikola-rebuilds-with-github-actions.html#rest_code_350e9be37c2943ab9a28489e74a58554-1"&gt;&lt;code data-line-number=" 1"&gt;&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;code&gt;&lt;a id="rest_code_350e9be37c2943ab9a28489e74a58554-1" name="rest_code_350e9be37c2943ab9a28489e74a58554-1"&gt;&lt;/a&gt;&lt;span class="nt"&gt;on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p p-Indicator"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;push&lt;/span&gt;&lt;span class="p p-Indicator"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="linenos linenodiv"&gt;&lt;a href="https://getnikola.com/blog/automating-nikola-rebuilds-with-github-actions.html#rest_code_350e9be37c2943ab9a28489e74a58554-2"&gt;&lt;code data-line-number=" 2"&gt;&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;code&gt;&lt;a id="rest_code_350e9be37c2943ab9a28489e74a58554-2" name="rest_code_350e9be37c2943ab9a28489e74a58554-2"&gt;&lt;/a&gt;
&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="linenos linenodiv"&gt;&lt;a href="https://getnikola.com/blog/automating-nikola-rebuilds-with-github-actions.html#rest_code_350e9be37c2943ab9a28489e74a58554-3"&gt;&lt;code data-line-number=" 3"&gt;&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;code&gt;&lt;a id="rest_code_350e9be37c2943ab9a28489e74a58554-3" name="rest_code_350e9be37c2943ab9a28489e74a58554-3"&gt;&lt;/a&gt;&lt;span class="nt"&gt;jobs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="linenos linenodiv"&gt;&lt;a href="https://getnikola.com/blog/automating-nikola-rebuilds-with-github-actions.html#rest_code_350e9be37c2943ab9a28489e74a58554-4"&gt;&lt;code data-line-number=" 4"&gt;&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;code&gt;&lt;a id="rest_code_350e9be37c2943ab9a28489e74a58554-4" name="rest_code_350e9be37c2943ab9a28489e74a58554-4"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;nikola_build&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="linenos linenodiv"&gt;&lt;a href="https://getnikola.com/blog/automating-nikola-rebuilds-with-github-actions.html#rest_code_350e9be37c2943ab9a28489e74a58554-5"&gt;&lt;code data-line-number=" 5"&gt;&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;code&gt;&lt;a id="rest_code_350e9be37c2943ab9a28489e74a58554-5" name="rest_code_350e9be37c2943ab9a28489e74a58554-5"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;runs-on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;ubuntu-latest&lt;/span&gt;
&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="linenos linenodiv"&gt;&lt;a href="https://getnikola.com/blog/automating-nikola-rebuilds-with-github-actions.html#rest_code_350e9be37c2943ab9a28489e74a58554-6"&gt;&lt;code data-line-number=" 6"&gt;&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;code&gt;&lt;a id="rest_code_350e9be37c2943ab9a28489e74a58554-6" name="rest_code_350e9be37c2943ab9a28489e74a58554-6"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;'Deploy&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;Nikola&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;to&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;GitHub&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;Pages'&lt;/span&gt;
&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="linenos linenodiv"&gt;&lt;a href="https://getnikola.com/blog/automating-nikola-rebuilds-with-github-actions.html#rest_code_350e9be37c2943ab9a28489e74a58554-7"&gt;&lt;code data-line-number=" 7"&gt;&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;code&gt;&lt;a id="rest_code_350e9be37c2943ab9a28489e74a58554-7" name="rest_code_350e9be37c2943ab9a28489e74a58554-7"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;steps&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="linenos linenodiv"&gt;&lt;a href="https://getnikola.com/blog/automating-nikola-rebuilds-with-github-actions.html#rest_code_350e9be37c2943ab9a28489e74a58554-8"&gt;&lt;code data-line-number=" 8"&gt;&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;code&gt;&lt;a id="rest_code_350e9be37c2943ab9a28489e74a58554-8" name="rest_code_350e9be37c2943ab9a28489e74a58554-8"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;Check out&lt;/span&gt;
&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="linenos linenodiv"&gt;&lt;a href="https://getnikola.com/blog/automating-nikola-rebuilds-with-github-actions.html#rest_code_350e9be37c2943ab9a28489e74a58554-9"&gt;&lt;code data-line-number=" 9"&gt;&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;code&gt;&lt;a id="rest_code_350e9be37c2943ab9a28489e74a58554-9" name="rest_code_350e9be37c2943ab9a28489e74a58554-9"&gt;&lt;/a&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="nt"&gt;uses&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;actions/checkout@v2&lt;/span&gt;
&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="linenos linenodiv"&gt;&lt;a href="https://getnikola.com/blog/automating-nikola-rebuilds-with-github-actions.html#rest_code_350e9be37c2943ab9a28489e74a58554-10"&gt;&lt;code data-line-number="10"&gt;&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;code&gt;&lt;a id="rest_code_350e9be37c2943ab9a28489e74a58554-10" name="rest_code_350e9be37c2943ab9a28489e74a58554-10"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;Build and Deploy Nikola&lt;/span&gt;
&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="linenos linenodiv"&gt;&lt;a href="https://getnikola.com/blog/automating-nikola-rebuilds-with-github-actions.html#rest_code_350e9be37c2943ab9a28489e74a58554-11"&gt;&lt;code data-line-number="11"&gt;&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;code&gt;&lt;a id="rest_code_350e9be37c2943ab9a28489e74a58554-11" name="rest_code_350e9be37c2943ab9a28489e74a58554-11"&gt;&lt;/a&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="nt"&gt;uses&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;getnikola/nikola-action@v2&lt;/span&gt;
&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;There might be a newer version of the action available, you can check the
latest version in the &lt;a class="reference external" href="https://github.com/getnikola/nikola-action"&gt;getnikola/nikola-action repo on GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By default, the action will install the latest stable release of &lt;code class="docutils literal"&gt;Nikola[extras]&lt;/code&gt;. If you want to use the bleeding-edge version from &lt;code class="docutils literal"&gt;master&lt;/code&gt;, or want to install some extra dependencies, you can provide a &lt;code class="docutils literal"&gt;requirements.txt&lt;/code&gt; file in the repository.&lt;/p&gt;
&lt;p&gt;Commit everything to GitHub:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code console"&gt;&lt;a id="rest_code_424074bc25e34f18a761a113a908f178-1" name="rest_code_424074bc25e34f18a761a113a908f178-1" href="https://getnikola.com/blog/automating-nikola-rebuilds-with-github-actions.html#rest_code_424074bc25e34f18a761a113a908f178-1"&gt;&lt;/a&gt;&lt;span class="go"&gt;git add .&lt;/span&gt;
&lt;a id="rest_code_424074bc25e34f18a761a113a908f178-2" name="rest_code_424074bc25e34f18a761a113a908f178-2" href="https://getnikola.com/blog/automating-nikola-rebuilds-with-github-actions.html#rest_code_424074bc25e34f18a761a113a908f178-2"&gt;&lt;/a&gt;&lt;span class="go"&gt;git commit -am "Automate builds with GitHub Actions"&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Hopefully, GitHub will build your site and deploy. Check the Actions tab in
your repository or your e-mail for build details. If there are any errors, make sure you followed this guide to the letter.&lt;/p&gt;
&lt;/section&gt;</description><category>automation</category><category>GitHub</category><category>GitHub Actions</category><category>tips</category><guid>https://getnikola.com/blog/automating-nikola-rebuilds-with-github-actions.html</guid><pubDate>Fri, 24 Apr 2020 22:24:48 GMT</pubDate></item></channel></rss>