name: "Publish Docker Images"
description: "Publish Docker Image to the provided registry"

inputs:
  registry:
    description: 'Docker registry'
    required: true
  username:
    description: 'login username'
    required: true
  password:
    description: 'login password'
    required: true
  dry-run:
    description: 'dry run flag'
    required: true
  tag_version:
    description: 'tag version'
    required: true

runs:
  using: "composite"
  steps:
    - name: Set up QEMU
      uses: docker/setup-qemu-action@v3

    - name: Set up Docker Buildx
      uses: docker/setup-buildx-action@v3

    - name: Login to Docker Registry
      uses: docker/login-action@v3
      with:
        registry: ${{ inputs.registry }}
        username: ${{ inputs.username }}
        password: ${{ inputs.password }}

    - name: Install dependencies and build project
      shell: bash
      run: |
        npm ci
        npm run build.release

    - name: Build and push multi-platform image
      uses: docker/build-push-action@v6
      with:
        context: .
        platforms: linux/amd64,linux/arm64
        push: ${{ inputs.dry-run != 'true' }}
        tags: ${{ inputs.registry }}/alfresco/alfresco-content-app:${{ inputs.tag_version }}
