name: deploy-local-acs
description: Deploy local ACS for E2E testing

inputs:
  docker_username:
    description: 'Docker username'
    required: true
  docker_password:
    description: 'Docker password'
    required: true
  quay_username:
    description: 'Quay username'
    required: true
  quay_password:
    description: 'Quay password'
    required: true

runs:
  using: "composite"
  steps:
    - uses: azure/setup-helm@1a275c3b69536ee54be43f2070a358922e12c8d4
      with:
        version: "3.14.3"

    - name: Login to Docker Hub
      uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1  # v3.5.0
      with:
        username: ${{ inputs.docker_username }}
        password: ${{ inputs.docker_password }}

    - name: Login to Quay.io
      uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1  # v3.5.0
      with:
        registry: quay.io
        username: ${{ inputs.quay_username }}
        password: ${{ inputs.quay_password }}

    - name: Setup cluster
      uses: Alfresco/alfresco-build-tools/.github/actions/setup-kind@v8.33.0
      with:
        ingress-nginx-ref: controller-v1.8.2
        ingress-creation-timeout: 180s

    - name: Set nginx ingress config
      shell: bash
      run: >-
        kubectl -n ingress-nginx patch cm ingress-nginx-controller
        -p '{"data": {"allow-snippet-annotations":"true"}}'

    - name: Create registries auth secret
      shell: bash
      run: >-
        kubectl create secret generic regcred
        --from-file=.dockerconfigjson=$HOME/.docker/config.json
        --type=kubernetes.io/dockerconfigjson

    - name: Add dependency chart repos
      shell: bash
      run: |
        helm repo add self https://alfresco.github.io/alfresco-helm-charts/
        helm repo add elastic https://helm.elastic.co/

    - name: Checkout acs-deployment sources
      uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
      with:
        repository: Alfresco/acs-deployment
        ref: v9.0.0
        path: acs-deployment

    - name: Helm install
      shell: bash
      run: >-
        helm dep build acs-deployment/helm/alfresco-content-services &&
        helm install acs acs-deployment/helm/alfresco-content-services
        --set global.search.sharedSecret="$(openssl rand -hex 24)"
        --values acs-deployment/test/enterprise-integration-test-values.yaml
        --values .github/acs-deployment-values-override.yaml

    - name: Wait for pods to be ready
      uses: Alfresco/alfresco-build-tools/.github/actions/kubectl-wait@v8.33.0
