## Copyright (C) 2026 - 2026 ENCRYPTED SUPPORT LLC <adrelanos@whonix.org>
## See the file COPYING for copying conditions.

## AI-Assisted

## Composite action: start a Debian-based docker container with
## systemd as PID 1; subsequent steps `docker exec <name> ...`
## against a real init. Caller runs on a host runner (no
## `container:` directive, which would override the ENTRYPOINT).

name: 'Launch systemd container'
description: 'Start a Debian-based docker container with systemd as PID 1; subsequent steps docker exec into it.'

inputs:
  image:
    description: 'Base image. Must be a Debian/Ubuntu where apt-get and systemd-sysv are available. Default: debian:trixie.'
    required: false
    default: 'debian:trixie'
  name:
    description: 'Container name. Subsequent docker exec steps reference this.'
    required: false
    default: 'ci-systemd'
  workspace-mount:
    description: 'Host directory mounted at /workspace inside the container. Default: github.workspace.'
    required: false
    default: ''
  apt-bootstrap-packages:
    description: 'Extra apt packages installed into the systemd image at build time. ca-certificates / sudo / git are useful defaults because most follow-on actions assume they exist.'
    required: false
    default: 'ca-certificates sudo git'
  wait-seconds:
    description: 'Maximum seconds to wait for systemd to reach running/degraded/maintenance state.'
    required: false
    default: '60'

runs:
  using: composite
  steps:
    - name: Launch systemd container
      shell: bash
      env:
        IMAGE: ${{ inputs.image }}
        CONTAINER_NAME: ${{ inputs.name }}
        WORKSPACE_MOUNT: ${{ inputs.workspace-mount != '' && inputs.workspace-mount || github.workspace }}
        APT_BOOTSTRAP_PACKAGES: ${{ inputs.apt-bootstrap-packages }}
        WAIT_SECONDS: ${{ inputs.wait-seconds }}
      run: "$GITHUB_ACTION_PATH/launch-systemd-container.sh"
