From 21ce49b769dbdc4daea54efe87d149525cd96090 Mon Sep 17 00:00:00 2001 From: Derek Slenk Date: Sun, 29 Jun 2025 22:35:02 -0400 Subject: [PATCH 1/9] Add GitHub Actions workflows for build and deployment - Add build.yml: builds Hugo site on all non-main branches and PRs - Add deploy.yml: builds and deploys to S3 + CloudFront on main branch pushes - Uses generic OIDC role for AWS authentication --- .github/workflows/build.yml | 36 ++++++++++++++++++++++++ .github/workflows/deploy.yml | 53 ++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..feb4067 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,36 @@ +name: Build Site + +on: + push: + branches-ignore: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: recursive + fetch-depth: 0 + + - name: Setup Hugo + uses: peaceiris/actions-hugo@v3 + with: + hugo-version: 'latest' + extended: true + + - name: Build Hugo site + run: hugo --minify + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: hugo-build + path: public/ + retention-days: 7 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..852b13e --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,53 @@ +name: Deploy to S3 + +on: + push: + branches: + - main + +permissions: + id-token: write + contents: read + +jobs: + deploy: + runs-on: ubuntu-latest + environment: prod + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: recursive + fetch-depth: 0 + + - name: Setup Hugo + uses: peaceiris/actions-hugo@v3 + with: + hugo-version: 'latest' + extended: true + + - name: Build Hugo site + run: hugo --minify + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.CC_OIDC_ROLE }} + aws-region: us-east-1 + + - name: Deploy to S3 + run: | + aws s3 sync public/ s3://angrymichigander.com --delete --no-cli-pager + + - name: Invalidate CloudFront cache + run: | + # Get the CloudFront distribution ID for angrymichigander.com + DISTRIBUTION_ID=$(aws cloudfront list-distributions --no-cli-pager --query "DistributionList.Items[?contains(Aliases.Items, 'angrymichigander.com')].Id" --output text) + + if [ ! -z "$DISTRIBUTION_ID" ]; then + echo "Creating CloudFront invalidation for distribution: $DISTRIBUTION_ID" + aws cloudfront create-invalidation --no-cli-pager --distribution-id $DISTRIBUTION_ID --paths "/*" + else + echo "No CloudFront distribution found for angrymichigander.com" + fi From 5a325d0273caaf15880f54f1042be3442a0b7e0f Mon Sep 17 00:00:00 2001 From: Derek Slenk Date: Sun, 29 Jun 2025 22:36:31 -0400 Subject: [PATCH 2/9] disable cloudfront deploy for now --- .github/workflows/deploy.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 852b13e..f04cb0c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -40,14 +40,14 @@ jobs: run: | aws s3 sync public/ s3://angrymichigander.com --delete --no-cli-pager - - name: Invalidate CloudFront cache - run: | - # Get the CloudFront distribution ID for angrymichigander.com - DISTRIBUTION_ID=$(aws cloudfront list-distributions --no-cli-pager --query "DistributionList.Items[?contains(Aliases.Items, 'angrymichigander.com')].Id" --output text) + # - name: Invalidate CloudFront cache + # run: | + # # Get the CloudFront distribution ID for angrymichigander.com + # DISTRIBUTION_ID=$(aws cloudfront list-distributions --no-cli-pager --query "DistributionList.Items[?contains(Aliases.Items, 'angrymichigander.com')].Id" --output text) - if [ ! -z "$DISTRIBUTION_ID" ]; then - echo "Creating CloudFront invalidation for distribution: $DISTRIBUTION_ID" - aws cloudfront create-invalidation --no-cli-pager --distribution-id $DISTRIBUTION_ID --paths "/*" - else - echo "No CloudFront distribution found for angrymichigander.com" - fi + # if [ ! -z "$DISTRIBUTION_ID" ]; then + # echo "Creating CloudFront invalidation for distribution: $DISTRIBUTION_ID" + # aws cloudfront create-invalidation --no-cli-pager --distribution-id $DISTRIBUTION_ID --paths "/*" + # else + # echo "No CloudFront distribution found for angrymichigander.com" + # fi From 0265c44006a214348b9e016e1b4d2ea021a93670 Mon Sep 17 00:00:00 2001 From: Derek Slenk Date: Sun, 29 Jun 2025 22:37:52 -0400 Subject: [PATCH 3/9] Update .github/workflows/build.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/build.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index feb4067..eafafcd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,8 +19,18 @@ jobs: submodules: recursive fetch-depth: 0 + - name: Cache Hugo modules + uses: actions/cache@v3 + with: + path: .hugo + key: ${{ runner.os }}-hugo-${{ steps.hugo-version.outputs.version }}-${{ hashFiles('**/go.mod') }} + restore-keys: | + ${{ runner.os }}-hugo-${{ steps.hugo-version.outputs.version }} + ${{ runner.os }}-hugo- + - name: Setup Hugo uses: peaceiris/actions-hugo@v3 + id: hugo-version with: hugo-version: 'latest' extended: true From 9dbd1af5f9202222b9338de193f1eac3396ff72f Mon Sep 17 00:00:00 2001 From: Derek Slenk Date: Thu, 17 Jul 2025 14:20:51 -0400 Subject: [PATCH 4/9] Add Forgejo Actions workflows for Hugo site MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add build workflow for PR validation - Add deploy workflow for main branch S3 deployment - Use self-hosted runners 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .forgejo/workflows/build.yml | 33 +++++++++++++++++++++++++++++++ .forgejo/workflows/deploy.yml | 37 +++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 .forgejo/workflows/build.yml create mode 100644 .forgejo/workflows/deploy.yml diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml new file mode 100644 index 0000000..6079e2d --- /dev/null +++ b/.forgejo/workflows/build.yml @@ -0,0 +1,33 @@ +name: Build Site + +on: + pull_request: + branches: + - main + +jobs: + build: + runs-on: self-hosted + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: recursive + fetch-depth: 0 + + - name: Setup Hugo + uses: peaceiris/actions-hugo@v3 + with: + hugo-version: 'latest' + extended: true + + - name: Build Hugo site + run: hugo --minify + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: hugo-build + path: public/ + retention-days: 7 \ No newline at end of file diff --git a/.forgejo/workflows/deploy.yml b/.forgejo/workflows/deploy.yml new file mode 100644 index 0000000..bc6b9c7 --- /dev/null +++ b/.forgejo/workflows/deploy.yml @@ -0,0 +1,37 @@ +name: Deploy to S3 + +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: self-hosted + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: recursive + fetch-depth: 0 + + - name: Setup Hugo + uses: peaceiris/actions-hugo@v3 + with: + hugo-version: 'latest' + extended: true + + - name: Build Hugo site + run: hugo --minify + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + + - name: Deploy to S3 + run: | + aws s3 sync public/ s3://${{ secrets.S3_BUCKET_NAME }} --delete --no-cli-pager \ No newline at end of file From a837049a4f1f2dd95e08396598ab0712bc90cca0 Mon Sep 17 00:00:00 2001 From: Derek Slenk Date: Thu, 17 Jul 2025 14:30:30 -0400 Subject: [PATCH 5/9] Add CLAUDE.md documentation for future Claude Code instances MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Includes project overview, development commands, architecture details, and tea CLI commands for Forgejo integration. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- CLAUDE.md | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..84fca11 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,74 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## Project Overview + +This is a Hugo static site generator project for "The Angry Michigander" blog. The site uses the Lynx theme (github.com/jpanther/lynx) via Hugo modules. + +## Development Commands + +- **Local development**: `hugo server -D` (serves locally with drafts) +- **Build for production**: `hugo --minify` (outputs to `public/` directory) +- **Build regular**: `hugo` (outputs to `public/` directory) + +## Architecture + +- **Framework**: Hugo static site generator with Go modules +- **Theme**: Lynx theme (github.com/jpanther/lynx v1.4.0) imported as Hugo module +- **Configuration**: hugo.yaml (main config file) +- **Content**: Markdown files in `content/` directory +- **Static assets**: `static/` directory for static files +- **Build output**: `public/` directory (generated, not tracked in git) + +## Key Files and Directories + +- `hugo.yaml` - Main Hugo configuration +- `go.mod` - Go module dependencies for Hugo modules +- `content/` - Markdown content files +- `archetypes/` - Content templates (default.md, post.md) +- `layouts/partials/` - Custom layout overrides +- `static/` - Static assets +- `assets/` - Source assets (CSS, images) + +## CI/CD + +The project has dual CI/CD setup: +- **GitHub Actions**: `.github/workflows/` (ubuntu-latest runner) +- **Forgejo Actions**: `.forgejo/workflows/` (self-hosted runner) + +Both include build and deploy workflows that: +1. Check out code with submodules +2. Set up Hugo extended version +3. Build with `hugo --minify` +4. Upload artifacts to `public/` directory + +## Forgejo Integration + +This project uses Forgejo for source control. Use the `tea` CLI tool (https://gitea.com/gitea/tea) for Forgejo operations instead of `gh` CLI: + +- **Setup**: `tea login add` (first-time setup) +- **List pull requests**: `tea pulls` or `tea pulls list` +- **Create pull request**: `tea pulls create` +- **View pull request**: `tea pulls [PR index]` +- **Merge pull request**: `tea pulls merge [PR index]` +- **List issues**: `tea issues` or `tea issues list` +- **Create issue**: `tea issues create` +- **View issue**: `tea issues [issue index]` + +Always prefer `tea` commands over `gh` commands when working with this repository's Forgejo instance. + +## Theme Customization + +The Lynx theme is used via Hugo modules. Custom overrides can be placed in: +- `layouts/` - Layout overrides +- `assets/css/custom.css` - Custom CSS +- `static/` - Static file overrides + +## Content Creation + +Use archetypes for new content: +- `archetypes/default.md` - Default content template +- `archetypes/post.md` - Blog post template with extensive frontmatter options + +Create new posts with: `hugo new posts/my-post.md` \ No newline at end of file From adeb2efd1e2f5d1a9edd9c41acceb8b0afe5e586 Mon Sep 17 00:00:00 2001 From: Derek Slenk Date: Thu, 17 Jul 2025 14:31:17 -0400 Subject: [PATCH 6/9] Remove GitHub Actions workflows in favor of Forgejo Actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GitHub Actions workflows are no longer needed since we're using Forgejo Actions for CI/CD on the self-hosted runner. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .github/workflows/build.yml | 46 ------------------------------- .github/workflows/deploy.yml | 53 ------------------------------------ 2 files changed, 99 deletions(-) delete mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index eafafcd..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Build Site - -on: - push: - branches-ignore: - - main - pull_request: - branches: - - main - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - submodules: recursive - fetch-depth: 0 - - - name: Cache Hugo modules - uses: actions/cache@v3 - with: - path: .hugo - key: ${{ runner.os }}-hugo-${{ steps.hugo-version.outputs.version }}-${{ hashFiles('**/go.mod') }} - restore-keys: | - ${{ runner.os }}-hugo-${{ steps.hugo-version.outputs.version }} - ${{ runner.os }}-hugo- - - - name: Setup Hugo - uses: peaceiris/actions-hugo@v3 - id: hugo-version - with: - hugo-version: 'latest' - extended: true - - - name: Build Hugo site - run: hugo --minify - - - name: Upload build artifacts - uses: actions/upload-artifact@v4 - with: - name: hugo-build - path: public/ - retention-days: 7 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index f04cb0c..0000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: Deploy to S3 - -on: - push: - branches: - - main - -permissions: - id-token: write - contents: read - -jobs: - deploy: - runs-on: ubuntu-latest - environment: prod - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - submodules: recursive - fetch-depth: 0 - - - name: Setup Hugo - uses: peaceiris/actions-hugo@v3 - with: - hugo-version: 'latest' - extended: true - - - name: Build Hugo site - run: hugo --minify - - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - role-to-assume: ${{ secrets.CC_OIDC_ROLE }} - aws-region: us-east-1 - - - name: Deploy to S3 - run: | - aws s3 sync public/ s3://angrymichigander.com --delete --no-cli-pager - - # - name: Invalidate CloudFront cache - # run: | - # # Get the CloudFront distribution ID for angrymichigander.com - # DISTRIBUTION_ID=$(aws cloudfront list-distributions --no-cli-pager --query "DistributionList.Items[?contains(Aliases.Items, 'angrymichigander.com')].Id" --output text) - - # if [ ! -z "$DISTRIBUTION_ID" ]; then - # echo "Creating CloudFront invalidation for distribution: $DISTRIBUTION_ID" - # aws cloudfront create-invalidation --no-cli-pager --distribution-id $DISTRIBUTION_ID --paths "/*" - # else - # echo "No CloudFront distribution found for angrymichigander.com" - # fi From c0d5b498ea3462dc9f6d2e7159c620a84bbc170c Mon Sep 17 00:00:00 2001 From: Derek Slenk Date: Thu, 17 Jul 2025 14:33:58 -0400 Subject: [PATCH 7/9] Fix Forgejo Actions to use GitHub action references MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Forgejo Actions doesn't have all GitHub Actions in its data repository, so we need to reference the full GitHub URLs for actions like peaceiris/actions-hugo and aws-actions/configure-aws-credentials. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .forgejo/workflows/build.yml | 6 +++--- .forgejo/workflows/deploy.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index 6079e2d..4d1543d 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -11,13 +11,13 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v4 + uses: https://github.com/actions/checkout@v4 with: submodules: recursive fetch-depth: 0 - name: Setup Hugo - uses: peaceiris/actions-hugo@v3 + uses: https://github.com/peaceiris/actions-hugo@v3 with: hugo-version: 'latest' extended: true @@ -26,7 +26,7 @@ jobs: run: hugo --minify - name: Upload build artifacts - uses: actions/upload-artifact@v4 + uses: https://github.com/actions/upload-artifact@v4 with: name: hugo-build path: public/ diff --git a/.forgejo/workflows/deploy.yml b/.forgejo/workflows/deploy.yml index bc6b9c7..87fa99e 100644 --- a/.forgejo/workflows/deploy.yml +++ b/.forgejo/workflows/deploy.yml @@ -11,13 +11,13 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v4 + uses: https://github.com/actions/checkout@v4 with: submodules: recursive fetch-depth: 0 - name: Setup Hugo - uses: peaceiris/actions-hugo@v3 + uses: https://github.com/peaceiris/actions-hugo@v3 with: hugo-version: 'latest' extended: true @@ -26,7 +26,7 @@ jobs: run: hugo --minify - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v4 + uses: https://github.com/aws-actions/configure-aws-credentials@v4 with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} From 0f6983565acbc0655be3c81c3bda43703a6ba12f Mon Sep 17 00:00:00 2001 From: Derek Slenk Date: Thu, 17 Jul 2025 14:34:36 -0400 Subject: [PATCH 8/9] Use correct action references for Forgejo Actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Forgejo has actions/checkout, actions/upload-artifact, and aws-actions/configure-aws-credentials in its data repository. Only peaceiris/actions-hugo needs the full GitHub URL. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .forgejo/workflows/build.yml | 4 ++-- .forgejo/workflows/deploy.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index 4d1543d..5fdfb18 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -11,7 +11,7 @@ jobs: steps: - name: Checkout code - uses: https://github.com/actions/checkout@v4 + uses: actions/checkout@v4 with: submodules: recursive fetch-depth: 0 @@ -26,7 +26,7 @@ jobs: run: hugo --minify - name: Upload build artifacts - uses: https://github.com/actions/upload-artifact@v4 + uses: actions/upload-artifact@v4 with: name: hugo-build path: public/ diff --git a/.forgejo/workflows/deploy.yml b/.forgejo/workflows/deploy.yml index 87fa99e..2105288 100644 --- a/.forgejo/workflows/deploy.yml +++ b/.forgejo/workflows/deploy.yml @@ -11,7 +11,7 @@ jobs: steps: - name: Checkout code - uses: https://github.com/actions/checkout@v4 + uses: actions/checkout@v4 with: submodules: recursive fetch-depth: 0 @@ -26,7 +26,7 @@ jobs: run: hugo --minify - name: Configure AWS credentials - uses: https://github.com/aws-actions/configure-aws-credentials@v4 + uses: aws-actions/configure-aws-credentials@v4 with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} From b660b9cd5d15498747e4844c09a4debda745e877 Mon Sep 17 00:00:00 2001 From: Derek Slenk Date: Thu, 17 Jul 2025 14:36:25 -0400 Subject: [PATCH 9/9] Downgrade upload-artifact to v3 for GHES compatibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit actions/upload-artifact@v4 is not supported on GHES/Forgejo Actions. Using v3 for compatibility. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .forgejo/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index 5fdfb18..f4e1943 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -26,7 +26,7 @@ jobs: run: hugo --minify - name: Upload build artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v3 with: name: hugo-build path: public/