Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/actionlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
paths:
# GitHub exposes both fields. Remove this when actionlint's schema includes them.
.github/workflows/jekyll-{build,preview-comment}.yml:
ignore:
- 'property "workflow_(repository|sha)" is not defined'
102 changes: 102 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
name: Theme CI
permissions: {}

on:
pull_request:
push:
branches:
- master
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
site:
name: Build the example site
uses: ./.github/workflows/jekyll-build.yml
permissions:
contents: read
with:
source_dir: example
config_files: example/_config.yml,example/_preview.yml

verify-preview:
name: Verify the rendered preview
if: github.event_name == 'pull_request'
needs: site
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout validation script
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.pull_request.head.sha }}
persist-credentials: false

- name: Download the same files offered to reviewers
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: ${{ needs.site.outputs.preview_artifact }}
path: ${{ runner.temp }}/preview

- name: Verify the published paths
run: |
ruby script/verify-preview.rb "$RUNNER_TEMP/preview/previews/42/ThemerrDB" \
/previews/42/ThemerrDB /previews/42 https://preview.example.org

- name: Test the Docker preview
run: |
container=$(docker run --rm -d -p 127.0.0.1:8080:80 \
--mount "type=bind,source=$RUNNER_TEMP/preview,target=/usr/share/nginx/html,readonly" nginx:alpine)
trap 'docker stop "$container" >/dev/null' EXIT
curl --retry 5 --retry-all-errors -fsS http://127.0.0.1:8080/ -o "$RUNNER_TEMP/preview-index.html"
grep 'url=/previews/42/ThemerrDB/' "$RUNNER_TEMP/preview-index.html"
curl -fsS http://127.0.0.1:8080/previews/42/ThemerrDB/catalog/index.json | grep 'SunshineStream'

comment-preview:
name: Post the preview command
if: >-
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.id == github.event.pull_request.base.repo.id
needs: verify-preview
uses: ./.github/workflows/jekyll-preview-comment.yml
permissions:
contents: read
actions: read
pull-requests: write

compatibility:
name: Check Jekyll 3 compatibility
runs-on: ubuntu-latest
permissions:
contents: read
env:
JEKYLL_VERSION: '~> 3.10.0'
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Set up Ruby
uses: ruby/setup-ruby@f9c4492e86def3e644ab32a0ef185eda5b0c20d0 # v1.342.0
with:
ruby-version: '3.3'
bundler-cache: true

- name: Build and verify both URL layouts
run: |
bundle exec jekyll build --source example --destination _site/root --config example/_config.yml
ruby script/verify-preview.rb _site/root '' https://app.lizardbyte.dev/ https://example.org
bundle exec jekyll build --source example --destination _site/nested \
--config example/_config.yml,example/_preview.yml
ruby script/verify-preview.rb _site/nested /previews/42/ThemerrDB /previews/42 https://preview.example.org

- name: Check the preview comment and build the gem
run: |
node --test script/preview.test.cjs
gem build jekyll-theme-jackal.gemspec
140 changes: 140 additions & 0 deletions .github/workflows/jekyll-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
---
name: Build Jekyll site
permissions: {}

on:
workflow_call:
inputs:
ruby_version:
description: Ruby version for the site build
type: string
default: '4.0'
source_dir:
description: Jekyll source directory, relative to the caller's checkout
type: string
default: '.'
bundle_dir:
description: Directory containing the site's Gemfile, relative to the caller's checkout
type: string
default: '.'
config_files:
description: Optional comma-separated Jekyll config files, relative to bundle_dir
type: string
default: ''
site_artifact:
description: Optional input artifact from an earlier job in this run, overlaid on source_dir
type: string
default: ''
extract_archive:
description: Optional ZIP, TAR, or TAR.GZ filename inside site_artifact
type: string
default: ''
upload_pages:
description: Package the rendered site for GitHub Pages on non-PR runs
type: boolean
default: false
outputs:
preview_artifact:
description: Name of the PR preview artifact
value: ${{ jobs.build.outputs.preview_artifact }}
pages_artifact:
description: Name of the GitHub Pages artifact
value: ${{ jobs.build.outputs.pages_artifact }}

jobs:
build:
name: Build site
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
preview_artifact: ${{ steps.names.outputs.preview }}
pages_artifact: ${{ steps.names.outputs.pages }}
env:
SITE_SOURCE: ${{ inputs.source_dir }}
BUNDLE_DIR: ${{ inputs.bundle_dir }}
CONFIG_FILES: ${{ inputs.config_files }}
SITE_ARTIFACT: ${{ inputs.site_artifact }}
EXTRACT_ARCHIVE: ${{ inputs.extract_archive }}
BUILD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
PREVIEW: ${{ github.event_name == 'pull_request' }}
UPLOAD_PAGES: >-
${{ inputs.upload_pages && github.ref_name == github.event.repository.default_branch &&
contains(fromJSON('["push","schedule","workflow_dispatch"]'), github.event_name) }}
steps:
- name: Checkout site at the build commit
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ env.BUILD_SHA }}
path: project
persist-credentials: false

- name: Checkout the reusable workflow tools
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: ${{ job.workflow_repository }}
ref: ${{ job.workflow_sha }}
path: jackal-tools
persist-credentials: false

- name: Download generated site input
if: inputs.site_artifact != ''
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: ${{ inputs.site_artifact }}
path: ${{ runner.temp }}/jackal-generated

- name: Prepare Jekyll input
id: prepare
run: python3 jackal-tools/script/prepare-site-input.py

- name: Set up Ruby
uses: ruby/setup-ruby@f9c4492e86def3e644ab32a0ef185eda5b0c20d0 # v1.342.0
with:
ruby-version: ${{ inputs.ruby_version }}
working-directory: ${{ steps.prepare.outputs.bundle_dir }}
bundler-cache: true

- name: Build with the site's bundle
working-directory: ${{ steps.prepare.outputs.bundle_dir }}
env:
JEKYLL_ENV: production
JEKYLL_SOURCE: ${{ steps.prepare.outputs.source_dir }}
run: bundle exec ruby "$GITHUB_WORKSPACE/jackal-tools/script/build-site.rb"

- name: Name the build artifacts
id: names
run: |
if [[ "$PREVIEW" == 'true' ]]; then
echo "preview=jackal-preview-${BUILD_SHA}-${GITHUB_RUN_ATTEMPT}" >> "$GITHUB_OUTPUT"
fi
if [[ "$UPLOAD_PAGES" == 'true' ]]; then
echo "pages=github-pages-${GITHUB_RUN_ATTEMPT}" >> "$GITHUB_OUTPUT"
fi

- name: Upload the rendered preview
if: steps.names.outputs.preview != ''
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: ${{ steps.names.outputs.preview }}
path: ${{ runner.temp }}/jackal-preview/
include-hidden-files: true
if-no-files-found: error
retention-days: 14

- name: Write the preview command to the run summary
if: steps.names.outputs.preview != ''
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const { formatPreview } = require('./jackal-tools/script/preview.cjs')
await core.summary.addRaw(formatPreview(context.repo, context.runId,
process.env.BUILD_SHA, process.env.GITHUB_RUN_ATTEMPT)).write()

- name: Package the site for GitHub Pages
if: steps.names.outputs.pages != ''
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
with:
name: ${{ steps.names.outputs.pages }}
path: ${{ runner.temp }}/jackal-site
include-hidden-files: true
38 changes: 38 additions & 0 deletions .github/workflows/jekyll-preview-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Comment with the Jekyll preview
permissions: {}

on:
workflow_call:
workflow_run:
workflows: [Theme CI]
types: [completed]

jobs:
comment:
if: >-
(github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.id == github.event.pull_request.base.repo.id) ||
(github.event_name == 'workflow_run' &&
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success')
runs-on: ubuntu-latest
permissions:
contents: read
actions: read
pull-requests: write
steps:
- name: Checkout the comment workflow tools
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

Check failure on line 26 in .github/workflows/jekyll-preview-comment.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make sure that no untrusted code is executed from a fork.

See more on https://sonarcloud.io/project/issues?id=LizardByte_jackle&issues=AaH2tAT7a6FRu8Nqr4p3&open=AaH2tAT7a6FRu8Nqr4p3&pullRequest=2
with:
repository: ${{ job.workflow_repository }}
ref: ${{ job.workflow_sha }}
path: jackal-tools
persist-credentials: false

- name: Post or update the preview comment
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const { reportPreview } = require('./jackal-tools/script/preview.cjs')
await reportPreview({ github, context })
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
# JetBrains IDEs
.idea/

# Local builds and Bundler state
.bundle/
.jekyll-cache/
.jekyll-metadata
.sass-cache/
_site/
/Gemfile.lock
*.gem
11 changes: 11 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
source "https://rubygems.org"

gemspec

# Set JEKYLL_VERSION=~>3.10.0 to test the GitHub Pages generation of Jekyll.
gem "jekyll", ENV.fetch("JEKYLL_VERSION", "~> 4.4.0")
# These libraries moved out of the default gem set in Ruby 3.4.
gem "base64", "~> 0.3"
gem "bigdecimal", ">= 3.0", "< 5"
gem "kramdown-parser-gfm", "~> 1.1"
gem "webrick", "~> 1.9"
Loading