variables:
    GIT_SUBMODULE_STRATEGY: recursive
    GIT_SUBMODULE_FORCE_HTTPS: 'true'
    PROJECT: red-ui
    DOCKERFILELOCATION: 'docker/$PROJECT/Dockerfile'

include:
    - project: 'gitlab/gitlab'
      ref: 'main'
      file: 'ci-templates/docker_build_nexus_v2.yml'
      rules:
          - if: $CI_PIPELINE_SOURCE != "schedule"

localazy update:
    image: node:20.5
    cache:
        - key:
              files:
                  - yarn.lock
          paths:
              - .yarn-cache/
    script:
        # - git config user.email "${CI_EMAIL}"
        # - git config user.name "${CI_USERNAME}"
        # - git remote add gitlab_origin https://${CI_USERNAME}:${CI_ACCESS_TOKEN}@gitlab.knecon.com/redactmanager/red-ui.git
        - git push https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.knecon.com/redactmanager/red-ui.git
        - cd tools/localazy
        - yarn install --cache-folder .yarn-cache
        - yarn start
        - cd ../..
        - git add .
        - |-
            CHANGES=$(git status --porcelain | wc -l)
            if [ "$CHANGES" -gt "0" ]
            then
              git status
              git commit -m "push back localazy update"
              git push gitlab_origin HEAD:${CI_COMMIT_REF_NAME}
              # git push https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.knecon.com/redactmanager/red-ui.git
              # git push
            fi
    rules:
        - if: $CI_PIPELINE_SOURCE == "schedule"
