Update jekyll-gh-pages.yml #6
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: Setup Jekyll | ||
run: | | ||
gem install bundler | ||
bundle install | ||
- name: Create Jekyll structure | ||
run: | | ||
# Create necessary directories | ||
mkdir -p _runbooks _layouts _includes assets/css | ||
# Create runbook layout | ||
cat > _layouts/runbook.html << 'EOL' | ||
--- | ||
layout: default | ||
--- | ||
<article class="runbook"> | ||
<header class="runbook-header"> | ||
<h1>{{ page.title }}</h1> | ||
</header> | ||
<div class="runbook-content"> | ||
{{ 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> | ||
EOL | ||
# Process runbook files | ||
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//' | sed 's/-/ /g') | ||
newname=$(basename "$file" | tr '[:upper:]' '[:lower:]' | sed 's/ /-/g' | sed 's/runbook\.md$/md/' | sed 's/[)(]//g') | ||
# Create new file with front matter | ||
cat > "_runbooks/$newname" << EOL | ||
--- | ||
layout: runbook | ||
title: "${title}" | ||
permalink: /runbooks/${newname%.*}/ | ||
--- | ||
EOL | ||
# Append original content, skipping any existing front matter | ||
if grep -q "^---" "$file"; then | ||
sed -e '1{/^---$/!q;};1,/^---$/d' "$file" >> "_runbooks/$newname" | ||
else | ||
cat "$file" >> "_runbooks/$newname" | ||
fi | ||
fi | ||
done | ||
# Create index page | ||
cat > index.md << 'EOL' | ||
--- | ||
layout: default | ||
title: Contrast Security Attack Detection Rules 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@v5 | ||
- name: Build with Jekyll | ||
run: 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 |