mirror of
https://github.com/jbowdre/runtimeterror.git
synced 2024-12-24 03:42:19 +00:00
update draft
This commit is contained in:
parent
12d0259442
commit
3ffca631c3
2 changed files with 20 additions and 81 deletions
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
title: "Deploy Hugo Neocities Github Actions"
|
||||
title: "Deploying a Hugo Site to Neocities with GitHub Actions"
|
||||
date: 2024-01-21
|
||||
# lastmod: 2024-01-21
|
||||
draft: true
|
||||
|
@ -13,29 +13,21 @@ tags:
|
|||
- meta
|
||||
- serverless
|
||||
---
|
||||
I came across [Neocities](https://neocities.org) many months ago, and got really excited by the premise: a free web host with the mission to bring back "the fun, creativity and independence that made the web great." I spent a while scrolling through the [gallery](https://neocities.org/browse) of personal sites and was amazed by both the nostalgia and the creativity on display. It's like a portal that took me back to when the web was fun. It sounded like something I wanted to be a part of, so I signed up for an account... and promptly realized that I didn't *really* want to go back to manually crafting HTML like I did with the sites I created in the early 2000s. I didn't see an easy way to connect my preferred static site generator, and I'm kind of lazy, so I stopped.
|
||||
|
||||
See, I was pretty happy with my existing publishing setup. I write posts in Markdown and commit/push those changes to GitHub. I've got [Netlify](https://netlify.com/) set up to watch my repo for changes, and when a `push` happens it springs into action. Netlify grabs the content of my repo, uses [Hugo](https://gohugo.io/) to render it to HTML, calls [Torchlight](/spotlight-on-torchlight/) to dress up the code blocks, and then serves the result through Netlify's global CDN. This process is automatic and reliable - and using an SSG like Hugo means I don't have to wrangle HTML with my bare hands.[^wrangling]
|
||||
|
||||
[^wrangling]: Though, admittedly, I've spent most of my free time this last week tinkering with HTML templates and fiddling with CSS bits... but that was for fun, dangit!
|
||||
|
||||
Supporter: https://neocities.org/supporter
|
||||
But then I joined the [omg.lol](https://home.omg.lol/) community a month or so ago, and that exposed me to some brilliant web developers doing awesome things in the name of an [independent, personal web](https://indieweb.org/). Seeing what other omg.lol members were doing with their personal web spaces inspired me to see if I could do a bit more with mine... and I've done a *lot* of small housekeeping improvements in that time. I implemented full-text RSS feeds (and deployed a [self-hosted feed reader](/tailscale-serve-docker-compose-sidecar/#miniflux) to follow other blogs), switched to using [tinylytics](https://tinylytics.app/) for analytics (and a slick no-account-needed Kudos button on each post), did a lot of reorganizing things, and performed a lot of other little tweaks along the way.
|
||||
|
||||
Netlify pricing: https://www.netlify.com/pricing/#core-pricing-table
|
||||
And yesterday, I saw a post from [Sophie](https://social.lol/@sophie) titled [How I deploy my Eleventy site to Neocities](https://localghost.dev/blog/how-i-deploy-my-eleventy-site-to-neocities/). Until reading her post, I hadn't realized that Neocities had an [API](https://neocities.org/api), or that there was a [deploy-to-neocities](https://github.com/bcomnes/deploy-to-neocities) GitHub Action which could use that API to push content to Neocities. With that new-to-me information, I quickly decided that I wanted to go ahead and make this change.
|
||||
|
||||
| | Neocities (free) | Neocities ($5/mo) | Netlify (free) | Netlify ($19/mo) |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| Storage | 1 GB | 50 GB | - | - |
|
||||
| Bandwidth | 200 GB | 3000 TB | 100 GB | 1000 TB |
|
||||
| Global CDN | ✅ | ✅ | ✅ | ✅ |
|
||||
| Analytics | ✅ | ✅ | $9/mo | $9/mo |
|
||||
| One-Click Backups | ✅ | ✅ | - | - |
|
||||
| Email Support | - | ✅ | - | ✅ |
|
||||
| Supports a free web | - | ✅ | - | - |
|
||||
Like I mentioned earlier, I didn't really have any complaints with Netlify, and I never came anywhere close to the bandwidth limits of the free plan. But I saw Neocities as a better vision of the internet, and I wanted to be a part of that. So I signed up for the $5/month [Neocities Supporter](https://neocities.org/supporter) plan so I could bring in my own domain *and* to support their vision.
|
||||
|
||||
Then I followed Sophie's instructions to obtain my Neocities API token and store it as a repository secret called `NEOCITIES_API_TOKEN`.
|
||||
|
||||
Sophie's post: https://localghost.dev/blog/how-i-deploy-my-eleventy-site-to-neocities/
|
||||
|
||||
Action: https://github.com/bcomnes/deploy-to-neocities
|
||||
|
||||
Hugo starter workflow: https://github.com/actions/starter-workflows/blob/main/pages/hugo.yml
|
||||
From there, I knew I'd need to make some changes to her workflow since I build my site with Hugo rather than Eleventy. I did some poking around and found [GitHub Actions for Hugo](https://github.com/peaceiris/actions-hugo) which would take care of installing Hugo for me. After some trial and error, I came up with this workflow:
|
||||
|
||||
|
||||
```yaml
|
||||
|
@ -43,100 +35,47 @@ Hugo starter workflow: https://github.com/actions/starter-workflows/blob/main/pa
|
|||
# .github/workflows/deploy-to-neocities.yml
|
||||
name: Deploy to Neocities
|
||||
|
||||
# only run on changes to main
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
concurrency: # prevent concurrent deploys doing strange things
|
||||
concurrency:
|
||||
group: deploy-to-neocities
|
||||
cancel-in-progress: true
|
||||
|
||||
# Default to bash
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build Hugo site
|
||||
deploy:
|
||||
name: Build and deploy Hugo site
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
HUGO_VERSION: "0.121.1"
|
||||
steps:
|
||||
- name: Install Hugo CLI
|
||||
run: |
|
||||
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
|
||||
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
|
||||
- name: Install Dart Sass
|
||||
run: sudo snap install dart-sass
|
||||
- name: Hugo setup
|
||||
uses: peaceiris/actions-hugo@v2.6.0
|
||||
with:
|
||||
hugo-version: '0.121.1'
|
||||
extended: true
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Install Node.js dependencies
|
||||
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
|
||||
- name: Build with Hugo
|
||||
env:
|
||||
# For maximum backward compatibility with Hugo modules
|
||||
HUGO_ENVIRONMENT: production
|
||||
HUGO_ENV: production
|
||||
run: |
|
||||
hugo \
|
||||
--minify
|
||||
run: hugo --minify
|
||||
- name: Insert 404 page
|
||||
run: |
|
||||
cp public/not_found/index.html public/not_found.html
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build
|
||||
path: public
|
||||
retention-days: 1
|
||||
|
||||
highlight:
|
||||
name: Highlight code with Torchlight
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Install Node.js dependencies
|
||||
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
|
||||
- name: Download artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: build
|
||||
path: public
|
||||
- name: Highlight with Torchlight
|
||||
run: |
|
||||
npm i @torchlight-api/torchlight-cli
|
||||
npx torchlight
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: highlight
|
||||
path: public
|
||||
retention-days: 1
|
||||
|
||||
deploy:
|
||||
name: Publish to Neocities
|
||||
runs-on: ubuntu-latest
|
||||
needs: highlight
|
||||
steps:
|
||||
- name: Download artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: highlight
|
||||
path: public
|
||||
- name: Deploy to neocities
|
||||
- name: Deploy to Neocities
|
||||
uses: bcomnes/deploy-to-neocities@v1
|
||||
with:
|
||||
api_token: ${{ secrets.NEOCITIES_API_TOKEN }}
|
||||
cleanup: false
|
||||
cleanup: true
|
||||
dist_dir: public
|
||||
```
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 170 KiB |
Loading…
Reference in a new issue