name: "MALCO's Daily Challenge"

on:
  schedule:
    - cron: '53 15 * * *' # 9:53 AM, UTC-6
  workflow_dispatch:

jobs:
  Build:
    runs-on: '${{ matrix.os }}'
    strategy:
      matrix:
        os:
          - ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          ref: 'stable'
      - name: Install dependencies (Ubuntu)
        if: runner.os == 'Linux'
        run: |
          sudo add-apt-repository -y ppa:bartbes/love-stable
          sudo apt-get -q update
          sudo apt-get install -y xvfb love
      - name: Generate Daily
        env:
          WEBHOOK: ${{ secrets.WEBHOOK }}
        run: |
          cd $GITHUB_WORKSPACE
          sudo xvfb-run -a --server-args="-screen 0 1024x768x24" love src --daily
          cat daily.txt
          curl -H "Content-Type: application/json" -X POST -d @daily.txt "$WEBHOOK"
