# Manual label trigger for the CI pipeline.
#
# CI no longer auto-triggers on push or pull_request — it runs only when a
# `ci` label is present on a PR (this workflow) or via workflow_dispatch from
# the Actions tab. The label gate keeps Actions minutes spend explicit.
#
# Behaviour:
#   - `labeled`     → runs only when the *just-added* label is `ci`.
#   - `synchronize` → re-runs CI on each new commit, but only while the `ci`
#                     label remains applied. Remove the label to stop further
#                     auto-runs; add it again to resume.
#   - `reopened`    → re-runs CI when a previously closed PR is reopened, if
#                     the `ci` label is still applied.
#
# Consumes 0 runner minutes for unrelated PRs / labels because the job guard
# (if:) is evaluated before any runner is provisioned.
name: CI (Manual Label)
permissions:
  contents: read
  pull-requests: read
  checks: write

on:
  pull_request:
    types: [labeled, synchronize, reopened]

jobs:
  ci:
    if: |
      (github.event.action == 'labeled' && github.event.label.name == 'ci') ||
      (github.event.action != 'labeled' && contains(github.event.pull_request.labels.*.name, 'ci'))
    uses: ./.github/workflows/ci.yml
