name: unity-composite
description: "Run a Unity command using a project's version and a build target. Then compress the result to a zip file."
inputs:
  platform:
    description: "Unity Platform. Options: windows, windows32bit, mac, linux, android"
    required: true
  email:
    description: "Unity email."
    required: true
  password:
    description: "Unity password."
    required: true
  command:
    description: "Unity command to run."
    required: false
  unityBuilder:
    description: "Whether or not to use the UnityBuilder instead of a Unity command."
    required: false
  buildDir:
    description: "Where the built application ends up."
    required: false
    default: build
  cacheVolume:
    description: "Name of the volume to cache the Library folder to."
    required: false
  artifactsVolume:
    description: "Name of the volume to copy the artifacts to."
    required: true
  artifactsDir:
    description: "Name of the directory to copy the artifacts from."
    required: true
    default: artifacts
  zipName:
    description: "Name of the resulting zip file."
    required: false
  artifactMode:
    description: "The mode with which to publish artifacts. Options: copy, own, or null Default: copy"
    required: false
    default: ""
runs:
  using: "composite"
  steps:
  - name: Checkout
    uses: actions/checkout@v2
  - uses: act/unity/unity-project@master
    with:
      platform: ${{ inputs.platform }}
      email: ${{ inputs.email }}
      password: ${{ inputs.password }}
      command: ${{ inputs.command }}
      unityBuilder: ${{ inputs.unityBuilder }}
      cacheVolume: ${{ inputs.cacheVolume }}
  - name: "Compress build"
    if: ${{ inputs.zipName }}
    env:
      WORKDIR: ${{ inputs.buildDir }}
    uses: act/common/utils/compress@master
    with:
      name: ../${{ inputs.artifactsDir }}/${{ inputs.zipName }}
      files: .
  - name: "Own artifacts"
    if: inputs.artifactMode == 'own'
    uses: act/common/utils/chown@master
    with:
      file: ${{ inputs.artifactsDir }}
  - name: "Copy artifacts"
    if: inputs.artifactMode == 'copy'
    uses: act/common/docker/docker-cp@master
    with:
      recreateVolume: true
      volume: ${{inputs.artifactsVolume }}
      fromPath: ${{ inputs.artifactsDir }}/.
