Update _config.yaml #8
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 Pages | |
uses: actions/configure-pages@v4 | |
- name: Create Jekyll structure | |
run: | | |
mkdir -p _runbooks _layouts _includes | |
# Create layout file | |
echo '---' > _layouts/runbook.html | |
echo 'layout: default' >> _layouts/runbook.html | |
echo '---' >> _layouts/runbook.html | |
echo '<article class="runbook">' >> _layouts/runbook.html | |
echo ' <h1>{{ page.title }}</h1>' >> _layouts/runbook.html | |
echo ' {{ content }}' >> _layouts/runbook.html | |
echo ' <footer><a href="{{ site.github.repository_url }}/edit/main/{{ page.path }}">Edit this page</a></footer>' >> _layouts/runbook.html | |
echo '</article>' >> _layouts/runbook.html | |
# Process runbooks | |
for file in runbooks/*.md; do | |
if [ -f "$file" ] && [ "$(basename "$file")" != "README.md" ]; then | |
filename=$(basename "$file" | tr '[:upper:]' '[:lower:]' | sed 's/ /-/g' | sed 's/runbook\.md$/md/' | sed 's/[)(]//g') | |
title=$(basename "$file" .md | sed 's/RunBook//') | |
# Create new runbook file with front matter | |
echo "---" > "_runbooks/$filename" | |
echo "layout: runbook" >> "_runbooks/$filename" | |
echo "title: \"$title\"" >> "_runbooks/$filename" | |
echo "permalink: /runbooks/${filename%.*}/" >> "_runbooks/$filename" | |
echo "---" >> "_runbooks/$filename" | |
# Append content, skipping any existing front matter | |
if grep -q "^---" "$file"; then | |
sed -e '1{/^---$/!q;};1,/^---$/d' "$file" >> "_runbooks/$filename" | |
else | |
cat "$file" >> "_runbooks/$filename" | |
fi | |
fi | |
done | |
# Create index page | |
echo "---" > index.md | |
echo "layout: default" >> index.md | |
echo "title: Contrast Security ADR Runbooks" >> index.md | |
echo "---" >> index.md | |
echo "" >> index.md | |
echo "# Attack Detection Rules (ADR) Runbooks" >> index.md | |
echo "" >> index.md | |
echo "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." >> index.md | |
echo "" >> index.md | |
echo "## Available Runbooks" >> index.md | |
echo "" >> index.md | |
echo "{% assign sorted_runbooks = site.runbooks | sort: 'title' %}" >> index.md | |
echo "{% for runbook in sorted_runbooks %}" >> index.md | |
echo "* [{{ runbook.title }}]({{ runbook.url | relative_url }})" >> index.md | |
echo "{% endfor %}" >> index.md | |
- name: Setup Dependencies | |
run: | | |
echo "source 'https://rubygems.org'" > Gemfile | |
echo "gem 'jekyll', '~> 4.2.0'" >> Gemfile | |
echo "gem 'minima'" >> Gemfile | |
echo "gem 'webrick'" >> Gemfile | |
bundle install | |
- name: Build with Jekyll | |
run: bundle exec jekyll build | |
env: | |
JEKYLL_ENV: production | |
- 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 |