Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

A GitHub Action to publish Jekyll based content as a GitHub Pages site

License

Notifications You must be signed in to change notification settings

root-project/jekyll-action

 
 

Repository files navigation

THIS CLONE IS ARCHIVED.

We don't need or use this anymore. It's just kept tempporarily to be able to roll back changes; it can and will be removed in the near future.

jekyll-action

A GitHub Action to build and publish Jekyll sites to GitHub Pages

Out-of-the-box Jekyll with GitHub Pages allows you to leverage a limited, white-listed, set of gems. Complex sites requiring custom ones or non white-listed ones (AsciiDoc for instance) used to require a continuous integration build in order to pre-process the site.

Usage

Create a Jekyll site

If your repository doesn't already have one, create a new Jekyll site: jekyll new sample-site. See the Jekyll website for more information. In this repository, we have created a site within a sample_site folder within the repository because the repository's main goal is not to be a website. If it was the case, we would have created the site at the root of the repository.

Create a Gemfile

As you are using this action to leverage specific Gems, well, you need to declare them! In the sample below we are using the Jekyll AsciiDoc plugin

source 'https://rubygems.org'

gem 'jekyll', '~> 3.8.5'
gem 'coderay', '~> 1.1.0'

group :jekyll_plugins do
  gem 'jekyll-asciidoc', '~> 2.1.1'
end

Configure your Jekyll site

Edit the configuration file of your Jekyll site (_config.yml) to leverage these plugins. In our sample, we want to leverage AsciiDoc so we added the following section:

asciidoc: {}
asciidoctor:
  base_dir: :docdir
  safe: unsafe
  attributes:
    - idseparator=_
    - source-highlighter=coderay
    - icons=font

Note that we also renamed index.html to index.adoc and modified this file accordingly in order to leverage AsciiDoc.

Use the action

Use the helaili/jekyll-action@master action in your workflow file. It needs access to a JEKYLL_PAT secret set with a Personal Access Token. The directory where the Jekyll site lives will be detected (based on the location of _config.yml) but you can also explicitly set this directory by setting the SRC environment variable (sample_site for us).

Note that it might be a good idea to use the actions/bin/filter action so the site is built only when a push happens on master.

image

workflow "Jekyll build now" {
  resolves = [
    "Jekyll Action",
  ]
  on = "push"
}

action "Jekyll Action" {
  uses = "helaili/jekyll-action@master"
  needs = "Filters for GitHub Actions"
  env = {
    SRC = "sample_site"
  }
  secrets = ["JEKYLL_PAT"]
}

action "Filters for GitHub Actions" {
  uses = "actions/bin/filter@b2bea0749eed6beb495a8fa194c071847af60ea1"
  args = "branch master"
}

Upon successful execution, the GitHub Pages publishing will happen automatically and will be listed on the environment tab of your repository.

image

Just click on the View deployment button of the github-pages environment to navigate to your GitHub Pages site.

image

Known Limitation

Publishing of the GitHub pages can fail when using the GITHUB_TOKEN secret instead of the JEKYLL_PAT. But it might work too 😄

About

A GitHub Action to publish Jekyll based content as a GitHub Pages site

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • CSS 81.1%
  • JavaScript 7.7%
  • HTML 7.0%
  • Dockerfile 2.1%
  • Shell 1.7%
  • Ruby 0.4%