zola publishing to garage from forgejo
I've switched to automatically running zola as a forgejo action to
push to garage, which was a bit annoying to make work. Here's a
full working example:
on: [push]
env:
ZOLA_VERSION: "0.21.0"
S3CMD_VERSION: "2.4.0"
UV_VERSION: "0.9.10"
S3_BUCKET: "staging"
S3_HOST: "192.0.2.1"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: https://code.forgejo.org/actions/checkout@v4
- name: Install Zola
run: |
mkdir -p ~/.zola
wget -q https://github.com/getzola/zola/releases/download/v${{ env.ZOLA_VERSION }}/zola-v${{ env.ZOLA_VERSION }}-x86_64-unknown-linux-gnu.tar.gz
tar -xzf zola-v${{ env.ZOLA_VERSION }}-x86_64-unknown-linux-gnu.tar.gz
mv zola ~/.zola/
rm zola-v${{ env.ZOLA_VERSION }}-x86_64-unknown-linux-gnu.tar.gz
- name: Add Zola to PATH
run: echo "$HOME/.zola" >> $GITHUB_PATH
- name: Verify Zola version
run: zola --version
- name: Build site
run: zola build -u /
- name: List build output
run: ls -la public/
- name: Install s3cmd with uv
run: |
curl -LsSf https://astral.sh/uv/${{ env.UV_VERSION }}/install.sh | sh
source $HOME/.local/bin/env
uv tool install s3cmd==${{ env.S3CMD_VERSION }}
- name: Upload to Garage S3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.STAGING_S3_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.STAGING_S3_SECRET_KEY }}
run: |
s3cmd sync ./public/ s3://${{ env.S3_BUCKET }}/ \
--access_key=$AWS_ACCESS_KEY_ID \
--secret_key=$AWS_SECRET_ACCESS_KEY \
--host=${{ env.S3_HOST }}:3900 \
--host-bucket=${{ env.S3_HOST }}:3900 \
--guess-mime-type \
--no-mime-magic \
--no-ssl \
--delete-removed
Something I hadn't anticipated, was that nginx would be getting the
mime-types from garage, and so this part is critical:
--guess-mime-type \
--no-mime-magic \
Without that, s3cmd seemingly guesses css files are text/plain,
and tells garage that, which tells nginx that, which causes modern
browsers to ignore style sheets entirely.