fix: remove frontmatter

This commit is contained in:
Dave Kerr
2025-03-31 08:27:42 +01:00
parent 32d95692c6
commit 2140429b95
5 changed files with 44 additions and 81 deletions

View File

View File

@@ -6,9 +6,12 @@ on:
pull_request: pull_request:
workflow_dispatch: workflow_dispatch:
# Permissions to check contents and open PR (release pleases) and update pages.
permissions: permissions:
contents: write contents: write
pull-requests: write pull-requests: write
pages: write
id-token: write
jobs: jobs:
test-website-build: test-website-build:
@@ -58,13 +61,13 @@ jobs:
# Set the env vars we use (version set for clarity). # Set the env vars we use (version set for clarity).
export DATE=$(date +%F) export DATE=$(date +%F)
export VERSION="${VERSION}" export VERSION="${VERSION}"
make prepare-markdown make -f .github/makefile prepare-markdown
env: env:
VERSION: ${{ needs.release.outputs.tag }} VERSION: ${{ needs.release.outputs.tag }}
# Create the PDF files. # Create the PDF files.
- name: Create PDF - name: Create PDF
run: make create-pdf run: make -f .github/makefile create-pdf
# Publish the PDF and intermediate markdown as an artifact. # Publish the PDF and intermediate markdown as an artifact.
# - name: Publish PDF Artifact # - name: Publish PDF Artifact
@@ -78,3 +81,28 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: | run: |
gh release upload "${{ needs.release.outputs.tag }}" --clobber hacker-laws.pdf hacker-laws.md gh release upload "${{ needs.release.outputs.tag }}" --clobber hacker-laws.pdf hacker-laws.md
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Build Website
run: |
cd .github/website
make install
make build
cp -r build/. '../pages'
ls -al "../pages"
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: './.github/pages'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

View File

@@ -1,69 +0,0 @@
# This pipeline builds the PDF ebook on any tag starting with 'v'.
name: "Create Release"
on:
push:
tags:
- 'v*'
jobs:
prepare-pdf:
# Focal Fossa. Please don't use 'latest' tags, it's an anti-pattern.
runs-on: ubuntu-20.04
steps:
# Checkout the code.
- name: Checkout
uses: actions/checkout@v2
# Set a descriptive version. For PRs it'll be the short sha.
- name: Set Version
id: set_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
# Prepare the content files.
- name: Prepare Content
run: ./scripts/prepare-markdown-for-ebook.sh ${{ steps.set_version.outputs.VERSION }}
# Create a PDF from the prepared markdown.
- name: Prepare PDF
uses: docker://pandoc/latex:2.9
with:
args: "-V toc-title:\"Table Of Contents\" --toc --pdf-engine=pdflatex --standalone --output hacker-laws.pdf hacker-laws.md"
# Publish the PDF artifact.
- name: Publish PDF Artifacts
uses: actions/upload-artifact@master
with:
name: hacker-laws.pdf
path: hacker-laws.pdf
release:
needs: prepare-pdf
runs-on: ubuntu-20.04
steps:
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: hacker-laws.pdf
- name: Create Release
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: |
Hacker Laws E-Book
draft: false
prerelease: false
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: ./hacker-laws.pdf
asset_name: hacker-laws.pdf
asset_content_type: application/pdf

View File

@@ -1,10 +1,3 @@
---
title: "Hacker Laws"
author: "Dave Kerr, github.com/dwmkerr/hacker-laws"
subtitle: "Laws, Theories, Principles, and Patterns that developers will find useful. ${VERSION}, ${DATE}."
version: ${VERSION}
---
<h1 align="center"><a href="https://hacker-laws.com" target="_blank">hacker-laws</a></h1> <h1 align="center"><a href="https://hacker-laws.com" target="_blank">hacker-laws</a></h1>
<h4 align="center">🧠 Laws, Theories, Principles and Patterns for developers and technologists.</h4> <h4 align="center">🧠 Laws, Theories, Principles and Patterns for developers and technologists.</h4>

View File

@@ -17,9 +17,20 @@ fi
export date="${DATE:-$(date +%F)}" export date="${DATE:-$(date +%F)}"
export version="${VERSION?error: VERSION must be set}" export version="${VERSION?error: VERSION must be set}"
# Update the input file to an intermedate. # Update the input file to an intermedate.
intermediate="${input}.temp" intermediate="${input}.temp"
DATE="${date}" VERSION="${version}" envsubst < "${input}" > "${intermediate}" cat <<EOF > "${intermediate}"
---
title: "Hacker Laws"
author: "Dave Kerr, github.com/dwmkerr/hacker-laws"
subtitle: "Laws, Theories, Principles, and Patterns that developers will find useful. ${VERSION}, ${DATE}."
version: ${VERSION}
---
EOF
cat "${input}" >> "${intermediate}"
DATE="${date}" VERSION="${version}" envsubst < "${intermediate}" > "${output}"
# Use a single `sed` command to clean up unwanted lines and emojis in one pass. # Use a single `sed` command to clean up unwanted lines and emojis in one pass.
sed -e '/💻📖.*/d' \ sed -e '/💻📖.*/d' \
@@ -27,7 +38,7 @@ sed -e '/💻📖.*/d' \
-e '/^\[Translations.*/d' \ -e '/^\[Translations.*/d' \
-e '/\*.*/d' \ -e '/\*.*/d' \
-e '/ \*.*/d' \ -e '/ \*.*/d' \
-e '/## Translations/,$d' "${intermediate}" > "${output}" -e '/## Translations/,$d' "${output}" > "${intermediate}"
rm "${intermediate}" mv "${intermediate}" "${output}"
echo "${output} prepared successfully." echo "${output} prepared successfully."