# Example: direct use of the afk-attempt composite action (the COMPOSABLE path).
#
# Use this when you want full control over triggers and gating and don't need the
# turnkey reusable workflow. The composite action is the execution PRIMITIVE
# (ADR 0062): it sets up Node, installs the runner CLI, and runs ONE AFK attempt
# against this repo's checkout. You own the trigger and any trust gate.
#
# Trade-off vs. the turnkey caller (`rs-afk-attempt.yml`): the reusable ships
# the author/label-actor trust gate (ADR 0085); the raw action does not. For
# public repos prefer the reusable. For private repos an `if:` on the actor (as
# below) is usually enough.
#
# Pin the action to a tag (`@v1`) for reproducible runs — that ref also fixes the
# `dev` bundle version the launcher fetches. Copy to `.github/workflows/afk.yml`.

name: afk
on:
  issues:
    types: [labeled, opened]
  workflow_dispatch:
    inputs:
      issue:
        description: "Issue number to process."
        required: true
        type: string

permissions:
  contents: write
  issues: write
  pull-requests: write

jobs:
  attempt:
    # Minimal inline gate: a labeled/opened issue carrying `ready-for-agent`,
    # applied by a trusted actor. EDIT the login list.
    if: >-
      github.event_name == 'workflow_dispatch' ||
      (
        contains(github.event.issue.labels.*.name, 'ready-for-agent') &&
        contains(fromJSON('["filipeforattini"]'), github.event.sender.login)
      )
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: reddb-io/red-skills/.github/actions/afk-attempt@v1
        with:
          issue: ${{ github.event.issue.number || inputs.issue }}
          runner: opencode
          # Wire whichever key your org provisions (first set wins; see
          # opencode-env.ts precedence). EDIT.
          openrouter-api-key: ${{ secrets.OPENROUTER_API_KEY }}
          minimax-api-key:    ${{ secrets.MINIMAX_API_KEY }}
          openai-api-key:     ${{ secrets.OPENAI_API_KEY }}
