Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/blog-quote.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ assignees: ""
---

---
layout: post
layout: quote
tags:
# source:
# link:
Expand Down
122 changes: 122 additions & 0 deletions .github/workflows/issue-to-post.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: Convert Issue to Blog Post

# ======================================================================
# WORKFLOW RELATIONSHIPS
# ======================================================================
# This workflow is part of a publishing pipeline:
#
# 1. This workflow (issue-to-post.yaml):
# - Triggers when a specific GitHub Issue is closed
# - Creates a new blog post based on the issue content
# - Commits and pushes the new post to the repository
#
# 2. When this workflow pushes to main, it automatically triggers:
# - The deploy.yaml workflow, which builds and deploys the site
#
# This creates an implicit chain:
# Issue closed → issue-to-post → [push to repo] → deploy workflow → [site deployed]
#
# No explicit workflow_call or workflow_dispatch dependencies are needed
# as GitHub's event system handles the chain through the push event.
# ======================================================================

on:
issues:
types: [closed]

# Permissions needed to create commits, push to the repository, and add a success comment
# to the issue.
permissions:
contents: write
issues: write

jobs:
create-post:
# Only run when:
# 1. The issue creator is @atenni (for security)
# 2. The closed issue has one of our blog-related labels
if: >
github.event.issue.user.login == 'atenni' &&
(contains(github.event.issue.labels.*.name, 'blog:post') ||
contains(github.event.issue.labels.*.name, 'blog:til') ||
contains(github.event.issue.labels.*.name, 'blog:quote'))
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Extract issue information
id: issue
run: |
# Extract the issue title and convert to lowercase with hyphens
# Remove special characters, replace spaces with hyphens, and collapse multiple hyphens to one
# Example: "one%$^ two---three" -> "one-two-three"
TITLE="${{ github.event.issue.title }}"
SLUG=$(echo "$TITLE" \
| tr '[:upper:]' '[:lower:]' \
| sed 's/[^a-z0-9 -]//g' \
| sed 's/ /-/g' \
| sed 's/-\{2,\}/-/g' \
| sed 's/^-\|-$//g')

# Get today's date in YYYY-MM-DD format
DATE=$(date +%Y-%m-%d)

# Determine post type based on labels
if [[ "${{ contains(github.event.issue.labels.*.name, 'blog:post') }}" == "true" ]]; then
POST_TYPE="post"
POST_DIR="posts/_posts"
elif [[ "${{ contains(github.event.issue.labels.*.name, 'blog:til') }}" == "true" ]]; then
POST_TYPE="til"
POST_DIR="til/_posts"
elif [[ "${{ contains(github.event.issue.labels.*.name, 'blog:quote') }}" == "true" ]]; then
POST_TYPE="quote"
POST_DIR="quoting/_posts"
fi

echo "DATE=$DATE" >> "$GITHUB_OUTPUT"
echo "SLUG=$SLUG" >> "$GITHUB_OUTPUT"
echo "POST_TYPE=$POST_TYPE" >> "$GITHUB_OUTPUT"
echo "POST_DIR=$POST_DIR" >> "$GITHUB_OUTPUT"
echo "FILENAME=${DATE}-${SLUG}.md" >> "$GITHUB_OUTPUT"
echo "FILEPATH=${POST_DIR}/${DATE}-${SLUG}.md" >> "$GITHUB_OUTPUT"

- name: Create post file
id: create-post
run: |
# Create directory if it doesn't exist
mkdir -p "${{ steps.issue.outputs.POST_DIR }}"

# Write the issue body to the post file unchanged (front matter is already present in the issue body)
printf "%s\n" "${{ github.event.issue.body }}" > "${{ steps.issue.outputs.FILEPATH }}"

echo "Created post at ${{ steps.issue.outputs.FILEPATH }}"

- name: Configure Git
run: |
# Act as the GitHub Actions bot user
# See: https://github.com/actions/checkout/blob/main/README.md#push-a-commit-using-the-built-in-token
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"

- name: Commit and push new post
run: |
git add "${{ steps.issue.outputs.FILEPATH }}"
git commit -m \
"ci: add new ${{ steps.issue.outputs.POST_TYPE }} from issue #${{ github.event.issue.number }}" \
|| echo "::notice::Nothing to commit" && exit 0
git push

echo "::notice::Post created and pushed to repository. This will trigger a deploy workflow if pushed to main."

- name: Add comment to issue
uses: actions/github-script@v6
with:
github-token: ${{ github.token }}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `✅ Successfully created a new blog post from this issue!\n\nPost file: \`${{ steps.issue.outputs.FILENAME }}\`\n\nThe post will be automatically published when the deploy workflow completes.`
})
2 changes: 1 addition & 1 deletion assets/css/components/header.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Site header
*/
.site-header {
border-top: 5px solid var(--grey-prominent);
border-top: 5px solid var(--brand-color);
border-bottom: 1px solid var(--grey-muted);
min-height: calc(var(--spacing-unit) * 1.865);
position: relative;
Expand Down
4 changes: 2 additions & 2 deletions assets/css/variables.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
/* prettier-ignore */
[data-theme="light"] {
--text-color: hsl(0, 0%, 10%);
--background-color: hsl(45, 5%, 90%);
--brand-color: hsl(214, 76%, 53%);
--background-color: hsl(45, 5%, 85%);
--brand-color: hsl(262, 83%, 60%);
--grey-neutral: hsl(0, 0%, 51%);
--grey-muted: hsl(0, 0%, 85%);
--grey-prominent: hsl(0, 0%, 26%);
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.0.0",
"description": "Static site generator for andrew.tennikoff.com",
"scripts": {
"dev": "bundle exec jekyll serve --livereload",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
Expand Down
File renamed without changes.
Loading