name: build-console-iso
run-name: ${{ github.actor }} - build-console-iso
on:
  schedule:
    - cron: '0 2 1,15 * *'
    # “At 02:00 on day-of-month 1 and 15.”
    
jobs:
  build-console-iso:
    runs-on: docker
    container: 
      image: alpine:edge
    steps:
    - name:  "Setup Runner"
      run: |
        apk update
        apk add git nodejs nix --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing/
    - uses: actions/checkout@v3
      with:
        sparse-checkout: |
          .forgejo
          home-manager 
          lib 
          nixos 
          flake.lock 
          flake.nix
          shell.nix
    - name: "Directory Structure"
      run: | 
        ls ${{ github.workspace }}/*
    - name: "Runner:  Node Info"
      run: |
        id
        uname -a
        hostname
        cat /etc/os-release
    - name: "Nix Version"
      run:  | 
        nix --version
    - name: "Nix build"
      run: | 
        echo "Running Nix Build"
        nix --extra-experimental-features "nix-command flakes" \
          build /workspace/albert/nix#imageConfigurations.nixos-iso-console
        echo "Results:"
        ls -lah result/iso/

    - if: always()
      run:  rm -rf /.cache
    - if: always()
      run: rm -rf ${{ github.workspace }}
    - if: failure()
      uses:  https://git.sysctl.io/actions/gotify-action@master
      with:
        gotify_api_base: '${{ secrets.GOTIFY_URL }}'
        gotify_app_token: '${{ secrets.GOTIFY_TOKEN }}'
        notification_title: '[ ${{ github.repository }}: ${{ github.workflow }} ] Build Failed'
        notification_message: 'Your build has failed.  Check Forgejo.'
      name:  "Send Notification"