---
name: "Prepare docker environment variables"
description: "Prepare docker environment variables"

inputs:
  image-name:
    required: true
    description: "Docker image prefix"
  image-arch:
    required: false
    description: "Docker image arch"
  release:
    required: true
    description: "True if this is a release build, false if this is a dev/PR build"

outputs:
  shouldPush:
    description: "Whether to push the image or not"
    value: ${{ steps.ev.outputs.shouldPush }}

  sha:
    description: "sha"
    value: ${{ steps.ev.outputs.sha }}

  version:
    description: "Version"
    value: ${{ steps.ev.outputs.version }}
  prerelease:
    description: "Prerelease"
    value: ${{ steps.ev.outputs.prerelease }}

  imageTags:
    description: "Docker image tags"
    value: ${{ steps.ev.outputs.imageTags }}
  imageTagsJSON:
    description: "Docker image tags, as a JSON array"
    value: ${{ steps.ev.outputs.imageTagsJSON }}
  attestImageNames:
    description: "Docker image names used for attestation"
    value: ${{ steps.ev.outputs.attestImageNames }}
  cacheTo:
    description: "cache-to value for the docker build step"
    value: ${{ steps.ev.outputs.cacheTo }}
  imageMainTag:
    description: "Docker image main tag"
    value: ${{ steps.ev.outputs.imageMainTag }}
  imageMainName:
    description: "Docker image main name"
    value: ${{ steps.ev.outputs.imageMainName }}
  imageBuildArgs:
    description: "Docker image build args"
    value: ${{ steps.ev.outputs.imageBuildArgs }}

runs:
  using: "composite"
  steps:
    - name: Setup authentik env
      uses: ./.github/actions/setup
      with:
        dependencies: "python"
    - name: Generate config
      id: ev
      shell: bash
      env:
        IMAGE_NAME: ${{ inputs.image-name }}
        IMAGE_ARCH: ${{ inputs.image-arch }}
        RELEASE: ${{ inputs.release }}
        PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
        REF: ${{ github.ref }}
      run: |
        uv run python3 ${{ github.action_path }}/push_vars.py
