name: Deploy to Codeberg Pages
on:
  push:
    branches: [main]
    paths: ['site_src/**', 'website/**']
  workflow_dispatch:

jobs:
  build-and-deploy:
    runs-on: codeberg-tiny
    container:
      image: alpine:edge
    steps:
      - name: Install prerequisites
        run: |
          echo "https://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
          apk update
          apk add --no-cache nodejs make lowdown
          apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/testing sblg

      - name: Checkout
        uses: https://code.forgejo.org/actions/checkout@v4

      - name: Build site
        working-directory: website
        run: make install PAGES_SRC_DIR=site_src

      - name: Deploy canonical (kewplayer.com)
        uses: https://codeberg.org/git-pages/action@v2
        with:
          server: codeberg.page
          site: 'https://kewplayer.com'
          token: ${{ forge.token }}
          source: pages/

      - name: Deploy www.kewplayer.com
        uses: https://codeberg.org/git-pages/action@v2
        with:
          server: codeberg.page
          site: "https://www.kewplayer.com"
          token: ${{ forge.token }}
          source: pages/

permissions:
  contents: write
