Skip to content

Create _config.yaml for Jekyll configuration. #2

Create _config.yaml for Jekyll configuration.

Create _config.yaml for Jekyll configuration. #2

name: Deploy Runbooks to GitHub Pages
on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true
- name: Create Jekyll structure
run: |
# Create necessary directories
mkdir -p _layouts _runbooks
# Create runbook layout
cat > _layouts/runbook.html << 'EOL'
---
layout: default
---
<article class="runbook">
<header class="runbook-header">
<h1>{{ page.title }}</h1>
{% if page.description %}
<p class="runbook-description">{{ page.description }}</p>
{% endif %}
</header>
<div class="runbook-content">
{{ content }}
</div>
<footer class="runbook-footer">
<p><a href="{{ site.github.repository_url }}/edit/main/{{ page.path }}">Edit this page on GitHub</a></p>
</footer>
</article>
EOL
# Move and rename runbooks
for file in runbooks/*.md; do
if [ -f "$file" ]; then
# Convert filename to lowercase, replace spaces with hyphens
newname=$(basename "$file" | tr '[:upper:]' '[:lower:]' | sed 's/ /-/g' | sed 's/runbook\.md$/md/')
# Add front matter if it doesn't exist
if ! grep -q "^---" "$file"; then
title=$(basename "$file" .md | sed 's/-/ /g' | sed 's/\b\(.\)/\u\1/g')
temp_file=$(mktemp)
echo "---" > "$temp_file"
echo "layout: runbook" >> "$temp_file"
echo "title: \"$title\"" >> "$temp_file"
echo "---" >> "$temp_file"
cat "$file" >> "$temp_file"
mv "$temp_file" "_runbooks/$newname"
else
mv "$file" "_runbooks/$newname"
fi
fi
done
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Build with Jekyll
uses: actions/jekyll-build-pages@v1
with:
source: ./
destination: ./_site
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4