# ### Action
#
# The action will run `docker compose up` to start the services defined in the given compose file(s).
# The compose file(s) can be specified using the `compose-file` input.
# Some extra options can be passed to the `docker compose up` command using the `up-flags` input.
#
# ### Post hook
#
# On post hook, the action will run `docker compose down` to clean up the services.
#
# Logs of the Docker Compose services are logged using GitHub `core.ts` API before the cleanup.
# The log level can be set using the `services-log-level` input.
# The default is `debug`, which will only print logs if [debug mode](https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/troubleshooting-workflows/enabling-debug-logging) is switched on.
#
# Some extra options can be passed to the `docker compose down` command using the `down-flags` input.
name: "Docker Compose Action"
description: This action runs your compose file(s) and clean up before action finished
author: "hoverkraft"
branding:
  icon: anchor
  color: blue

inputs:
  docker-flags:
    description: "Additional options to pass to `docker` command."
    required: false
  compose-file:
    description: "Path to compose file(s). It can be a list of files. It can be absolute or relative to the current working directory (cwd), or an OCI artifact reference starting with `oci://`."
    required: false
    default: "./docker-compose.yml"
  services:
    description: "Services to perform `docker compose up`."
    required: false
  up-flags:
    description: "Additional options to pass to `docker compose up` command."
    required: false
    default: ""
  down-flags:
    description: "Additional options to pass to `docker compose down` command."
    required: false
    default: ""
  compose-flags:
    description: "Additional options to pass to `docker compose` command."
    required: false
    default: ""
  cwd:
    description: "Current working directory"
    required: false
    default: ${{ github.workspace }}
  compose-version:
    description: |
      Compose version to use.
      If null (default), it will use the current installed version.
      If "latest", it will install the latest version.
    required: false
  services-log-level:
    description: |
      The log level used for Docker Compose service logs.
      Can be one of "debug", "info".
    required: false
    default: "debug"
  github-token:
    description: The GitHub token used to create an authenticated client (to fetch the latest version of Docker Compose).
    default: ${{ github.token }}
    required: false

runs:
  using: node20
  main: dist/index.js
  post: dist/post.js
