Update jekyll-gh-pages.yml #10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Security Runbooks to GitHub Pages | |
on: | |
push: | |
branches: ["main"] | |
workflow_dispatch: | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
concurrency: | |
group: "pages" | |
cancel-in-progress: false | |
jobs: | |
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 Files | |
run: | | |
# Create directories | |
mkdir -p _runbooks _layouts _includes assets/css | |
# Create _config.yml | |
cat > _config.yml << 'EOL' | |
title: Contrast Security ADR Runbooks | |
description: Security runbooks for Contrast Security's Attack Detection Rules | |
baseurl: "/adr-runbooks" | |
url: "https://contrast-security-oss.github.io" | |
repository: Contrast-Security-OSS/adr-runbooks | |
theme: minima | |
markdown: kramdown | |
kramdown: | |
input: GFM | |
hard_wrap: true | |
syntax_highlighter: rouge | |
parse_block_html: true | |
auto_ids: true | |
collections: | |
runbooks: | |
output: true | |
permalink: /runbooks/:title/ | |
defaults: | |
- scope: | |
path: "" | |
type: runbooks | |
values: | |
layout: runbook | |
exclude: | |
- README.md | |
- Gemfile | |
- Gemfile.lock | |
- vendor | |
- .git/ | |
EOL | |
# Create layout file | |
cat > _layouts/runbook.html << 'EOL' | |
--- | |
layout: default | |
--- | |
<article class="runbook"> | |
<header class="runbook-header"> | |
<h1>{{ page.title }}</h1> | |
</header> | |
<div class="runbook-content markdown-body"> | |
{{ content }} | |
</div> | |
<footer class="runbook-footer"> | |
<hr> | |
<p> | |
<a href="{{ site.github.repository_url }}/edit/main/{{ page.path }}">Edit this page on GitHub</a> | |
</p> | |
</footer> | |
</article> | |
<style> | |
.runbook { | |
max-width: 900px; | |
margin: 0 auto; | |
padding: 20px; | |
} | |
.runbook-content { | |
line-height: 1.6; | |
} | |
.runbook-content pre { | |
white-space: pre-wrap; | |
word-wrap: break-word; | |
background-color: #f6f8fa; | |
padding: 16px; | |
border-radius: 3px; | |
} | |
.runbook-content code { | |
font-family: monospace; | |
background-color: #f6f8fa; | |
padding: 2px 4px; | |
border-radius: 3px; | |
} | |
.runbook-content h2 { | |
margin-top: 2em; | |
margin-bottom: 1em; | |
padding-bottom: 0.3em; | |
border-bottom: 1px solid #eaecef; | |
} | |
.runbook-content ul { | |
margin-bottom: 1em; | |
} | |
.runbook-content li { | |
margin: 0.5em 0; | |
} | |
</style> | |
EOL | |
# Create Gemfile | |
cat > Gemfile << 'EOL' | |
source "https://rubygems.org" | |
gem "jekyll", "~> 4.2.0" | |
gem "minima" | |
gem "webrick" | |
EOL | |
- name: Process Runbooks | |
run: | | |
for file in runbooks/*.md; do | |
if [ -f "$file" ] && [ "$(basename "$file")" != "README.md" ]; then | |
# Get clean title and filename | |
title=$(basename "$file" .md | sed 's/RunBook//') | |
newname=$(basename "$file" | tr '[:upper:]' '[:lower:]' | sed 's/ /-/g' | sed 's/runbook\.md$/md/' | sed 's/[)(]//g') | |
# Create temporary file | |
temp_file=$(mktemp) | |
# Add front matter | |
echo "---" > "$temp_file" | |
echo "layout: runbook" >> "$temp_file" | |
echo "title: \"$title\"" >> "$temp_file" | |
echo "permalink: /runbooks/${newname%.*}/" >> "$temp_file" | |
echo "---" >> "$temp_file" | |
echo "" >> "$temp_file" | |
# Process the content: | |
# 1. Remove HTML comments | |
# 2. Ensure proper line breaks | |
# 3. Convert backslash line breaks to two spaces | |
sed -e 's/<!--.*-->//g' \ | |
-e 's/\\\\/\n/g' \ | |
-e 's/\\$/ /g' \ | |
-e 's/^#/\n#/g' \ | |
"$file" | grep -v '^[[:space:]]*$' >> "$temp_file" | |
# Move to final location | |
mv "$temp_file" "_runbooks/$newname" | |
fi | |
done | |
# Create index page | |
cat > index.md << 'EOL' | |
--- | |
layout: default | |
title: Contrast Security ADR Runbooks | |
--- | |
# Attack Detection Rules (ADR) Runbooks | |
Welcome to Contrast Security's Attack Detection Rules (ADR) Runbooks. These guides provide detailed procedures for understanding and responding to various security vulnerabilities detected by Contrast Security. | |
## Available Runbooks | |
{% assign sorted_runbooks = site.runbooks | sort: "title" %} | |
{% for runbook in sorted_runbooks %} | |
* [{{ runbook.title }}]({{ runbook.url | relative_url }}) | |
{% endfor %} | |
## Contributing | |
These runbooks are open source. To contribute: | |
1. Fork the [repository](https://github.com/Contrast-Security-OSS/adr-runbooks) | |
2. Make your changes | |
3. Submit a pull request | |
EOL | |
- name: Setup Pages | |
uses: actions/configure-pages@v4 | |
- name: Build Site | |
run: | | |
bundle install | |
bundle exec jekyll build | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: ./_site | |
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 |