From d799776fbab950ffc189afc422eea8ba93becfce Mon Sep 17 00:00:00 2001 From: Andrew T Date: Mon, 14 Apr 2025 07:59:31 +0000 Subject: [PATCH 1/6] refactor: add dev server npm script --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index a3b3399..54395f8 100644 --- a/package.json +++ b/package.json @@ -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": { From eeb861a7601eff0107fd60230c8e592d0d46b784 Mon Sep 17 00:00:00 2001 From: Andrew T Date: Tue, 15 Apr 2025 20:28:45 +0000 Subject: [PATCH 2/6] refactor: move posts to their own category --- {_posts => posts/_posts}/2025-04-14-friction.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {_posts => posts/_posts}/2025-04-14-friction.md (100%) diff --git a/_posts/2025-04-14-friction.md b/posts/_posts/2025-04-14-friction.md similarity index 100% rename from _posts/2025-04-14-friction.md rename to posts/_posts/2025-04-14-friction.md From a33d21f52d79731ee298794ab79381ee20d47a86 Mon Sep 17 00:00:00 2001 From: Andrew T Date: Tue, 15 Apr 2025 20:29:50 +0000 Subject: [PATCH 3/6] style: apply brand colour more uniformly --- assets/css/components/header.css | 2 +- assets/css/variables.css | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/css/components/header.css b/assets/css/components/header.css index 3ec3f62..16c0e1e 100644 --- a/assets/css/components/header.css +++ b/assets/css/components/header.css @@ -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; diff --git a/assets/css/variables.css b/assets/css/variables.css index 36f6fb7..0b61d47 100644 --- a/assets/css/variables.css +++ b/assets/css/variables.css @@ -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%); From 28a7e5b6e64e6127911564a93116a52da394a899 Mon Sep 17 00:00:00 2001 From: Andrew T Date: Tue, 15 Apr 2025 20:30:27 +0000 Subject: [PATCH 4/6] refactor: use quote layout --- .github/ISSUE_TEMPLATE/blog-quote.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/blog-quote.md b/.github/ISSUE_TEMPLATE/blog-quote.md index 6c53b12..974b393 100644 --- a/.github/ISSUE_TEMPLATE/blog-quote.md +++ b/.github/ISSUE_TEMPLATE/blog-quote.md @@ -8,7 +8,7 @@ assignees: "" --- --- -layout: post +layout: quote tags: # source: # link: From a861434dbac1bdd5a61f1c3b8f09243a42d85b44 Mon Sep 17 00:00:00 2001 From: Andrew T Date: Tue, 15 Apr 2025 20:30:59 +0000 Subject: [PATCH 5/6] wip --- .github/workflows/issue-to-post.yaml | 130 +++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 .github/workflows/issue-to-post.yaml diff --git a/.github/workflows/issue-to-post.yaml b/.github/workflows/issue-to-post.yaml new file mode 100644 index 0000000..bf36c4e --- /dev/null +++ b/.github/workflows/issue-to-post.yaml @@ -0,0 +1,130 @@ +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 and push to the repository +permissions: + contents: write + issues: read + +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: Set up Ruby + # uses: ruby/setup-ruby@v1 + # with: + # ruby-version: "3.x" + + - name: Extract issue information + id: issue + run: | + # Extract the issue title and convert to lowercase with hyphens + # Remove special characters and replace spaces with hyphens + TITLE="${{ github.event.issue.title }}" + SLUG=$(echo "$TITLE" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9 -]//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 }}" + + # Extract the issue body and strip any GitHub comment syntax + ISSUE_BODY="${{ github.event.issue.body }}" + + # Create the post file with front matter + cat > "${{ steps.issue.outputs.filepath }}" << EOL + --- + layout: ${{ steps.issue.outputs.post_type }} + title: "${{ github.event.issue.title }}" + date: ${{ steps.issue.outputs.date }} + categories: [${{ steps.issue.outputs.post_type }}] + tags: [${{ join(github.event.issue.labels.*.name, ', ') }}] + --- + + ${ISSUE_BODY} + + EOL + + echo "Created post at ${{ steps.issue.outputs.filepath }}" + + - name: Configure Git + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + + - name: Commit and push new post + run: | + git add "${{ steps.issue.outputs.filepath }}" + git commit -m "Add new ${{ steps.issue.outputs.post_type }} from issue #${{ github.event.issue.number }}" + git push origin ${GITHUB_REF##*/} + + echo "::notice::Post created and pushed to repository. This will trigger your deploy workflow if pushed to main." + + - name: Add comment to issue + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.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.` + }) From 3d537d1d4f54bb6d2f4d4b1a02f473d48a103b57 Mon Sep 17 00:00:00 2001 From: Andrew T Date: Fri, 18 Apr 2025 01:47:53 +0000 Subject: [PATCH 6/6] ci: increase error resilience for issue posting --- .github/workflows/issue-to-post.yaml | 74 +++++++++++++--------------- 1 file changed, 33 insertions(+), 41 deletions(-) diff --git a/.github/workflows/issue-to-post.yaml b/.github/workflows/issue-to-post.yaml index bf36c4e..2d60411 100644 --- a/.github/workflows/issue-to-post.yaml +++ b/.github/workflows/issue-to-post.yaml @@ -24,10 +24,11 @@ on: issues: types: [closed] -# Permissions needed to create commits and push to the repository +# Permissions needed to create commits, push to the repository, and add a success comment +# to the issue. permissions: contents: write - issues: read + issues: write jobs: create-post: @@ -44,18 +45,19 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - # - name: Set up Ruby - # uses: ruby/setup-ruby@v1 - # with: - # ruby-version: "3.x" - - name: Extract issue information id: issue run: | # Extract the issue title and convert to lowercase with hyphens - # Remove special characters and replace spaces 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') + 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) @@ -72,59 +74,49 @@ jobs: 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 + 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 }}" - - # Extract the issue body and strip any GitHub comment syntax - ISSUE_BODY="${{ github.event.issue.body }}" - - # Create the post file with front matter - cat > "${{ steps.issue.outputs.filepath }}" << EOL - --- - layout: ${{ steps.issue.outputs.post_type }} - title: "${{ github.event.issue.title }}" - date: ${{ steps.issue.outputs.date }} - categories: [${{ steps.issue.outputs.post_type }}] - tags: [${{ join(github.event.issue.labels.*.name, ', ') }}] - --- - - ${ISSUE_BODY} + mkdir -p "${{ steps.issue.outputs.POST_DIR }}" - EOL + # 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 }}" + echo "Created post at ${{ steps.issue.outputs.FILEPATH }}" - name: Configure Git run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" + # 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 "Add new ${{ steps.issue.outputs.post_type }} from issue #${{ github.event.issue.number }}" - git push origin ${GITHUB_REF##*/} + 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 your deploy workflow if pushed to main." + 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: ${{ secrets.GITHUB_TOKEN }} + 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.` + 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.` })