name: Build runner image

on:
  push:
    branches:
      - main
    paths:
      - requirements.lock
      - .dockerignore
      - .gitea/workflows/build-runner-image.yml
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    container:
      image: mahgit.ir/meghdadfadaee/build-runner-image-base:node-20-bookworm
      credentials:
        username: ${{ secrets.REGISTRY_USERNAME }}
        password: ${{ secrets.REGISTRY_TOKEN }}
    steps:
      - name: Check out repository
        uses: https://gitea.com/actions/checkout@v4

      - name: Build, verify, and publish image
        uses: https://mahgit.ir/MeghdadFadaee/build-runner-image-action@v1.0.2
        with:
          registry: mahgit.ir
          image: mahgit.ir/meghdadfadaee/daily-blackout-check-runner
          source-url: https://mahgit.ir/MeghdadFadaee/daily-blackout-check
          registry-username: ${{ secrets.REGISTRY_USERNAME }}
          registry-token: ${{ secrets.REGISTRY_TOKEN }}
          verify-commands: |
            docker run --rm "$IMAGE_REF" python -c "import dotenv, jdatetime, requests"
            docker run --rm "$IMAGE_REF" pytest --version
            docker run --rm "$IMAGE_REF" ruff --version
            docker run --rm "$IMAGE_REF" bash -lc \
              'command -v bash curl jq date && jq --version'
