name: Docs Deployment

on:
  workflow_dispatch:
  push:
    branches:
      - master

env:
  CARGO_TERM_COLOR: always
  RUST_LOG: debug

jobs:
  deploy:
    runs-on: ubuntu-latest
    environment: docs
    steps:
      - uses: actions/checkout@v3

      - name: Build static files
        run: |
          cargo build --release
          target/release/lssg --no-media-optimization docs/lssg.md build/
          # FIXME temporary hack to support 404 pages, change when you can keep the name
          mv build/404/index.html build/404.html
          rm -r build/404

      - name: Deploy to external repository
        uses: cpina/github-action-push-to-another-repository@main
        env:
          API_TOKEN_GITHUB: ${{ secrets.EXTERNAL_REPOSITORY_PERSONAL_ACCESS_TOKEN }}
        with:
          source-directory: build/
          destination-github-username: lyr-7d1h
          destination-repository-name: lssg-docs
          user-email: lyr-7d1h@pm.me
          target-branch: master
