name: Environment build test

on:
  push:

jobs:
  install:
    strategy:
      matrix:
        os: [ubuntu-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - name: Install chezmoi
        run: sh -c "cd /usr/local && $(curl -fsLS get.chezmoi.io)"

      - name: Install system dependencies
        run: sudo apt install -y libsqlite3-dev
        if: matrix.os == 'ubuntu-latest'

      - name: Bootstrap environment
        run: |
          mkdir -p $HOME/.config/chezmoi/
          mkdir -p $HOME/.local/share
          touch $HOME/.config/chezmoi/chezmoi.toml
          echo '  [data]' >> $HOME/.config/chezmoi/chezmoi.toml
          echo '    email = "john.doe@example.com"' >> $HOME/.config/chezmoi/chezmoi.toml
          echo '    name = "jdoe"' >> $HOME/.config/chezmoi/chezmoi.toml
          echo '    signingkey = "" ' >> $HOME/.config/chezmoi/chezmoi.toml
          echo '    font_size = "10"' >> $HOME/.config/chezmoi/chezmoi.toml
          echo '    dark = false' >> $HOME/.config/chezmoi/chezmoi.toml

      - name: Initialize chezmoi
        run: /usr/local/bin/chezmoi init -v zegervdv --branch ${GITHUB_REF##*/}

      - name: Apply dotfiles
        run: /usr/local/bin/chezmoi apply
        env:
          HOMEBREW_NO_INSTALL_FROM_API: 1
