name: Build and Run

on:
  push:
    branches:
      - main

jobs:
  build-and-run:
    runs-on: ubuntu-latest

    steps:
      - name: 1. Checkout repository
        uses: actions/checkout@v4

      - name: 2. Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.11'

      - name: 3. Install
        run: |
          pip install --upgrade pip
          pip install -r requirements.txt

      - name: 4. Run
        run: |
          python ./main.py &
          sleep 7

      - name: 5. Build
        run: |
          wget http://localhost:7777

      - name: 6. Log
        run: |
          cat endofyear.log

      - name: 7. Push static HTML
        uses: peaceiris/actions-gh-pages@v3
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./static
          publish_branch: html