name: test

on:
  push:
    branches:
      - main

jobs:
  test:
    runs-on: ubuntu-22.04
    environment: garage
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: true  # Fetch Hugo themes (true OR recursive)
          fetch-depth: 0    # Fetch all history for .GitInfo and .Lastmod

      - name: Setup Hugo
        uses: peaceiris/actions-hugo@v2
        with:
          hugo-version: 'latest'
          # extended: true

      - name: Setup Rust
        uses: dtolnay/rust-toolchain@stable        

      - name: Build website
        run: cargo run --manifest-path ./builder/Cargo.toml build

      - name: Deploy website
        run: |
          aws configure set default.s3.addressing_style path
          aws s3 sync ./dist s3://noratrieb.dev
        env:
          AWS_ACCESS_KEY_ID: "${{ secrets.AWS_KEY_ID }}"
          AWS_SECRET_ACCESS_KEY: "${{ secrets.AWS_SECRET_KEY }}"
          AWS_REGION: garage
          AWS_ENDPOINT_URL: https://garage.noratrieb.dev
