Child-pipeline should run only when there is a task to run else avoid running it

:hugs: Please help fill in this template with all the details to help others help you more efficiently. Use formatting blocks for code, config, logs and ensure to remove sensitive data.

Problem to solve

The child-pipeline stage should run only whenever there are changes in the generate-config.yml file , else should not run or fail it coz sometimes like feature-branch we wont have any child-jobs to run

Problem is the child-pipeline doesn’t shows up

Configuration

.gitlab-ci.yml file …Below is for testing purpose

generate-config:
  stage: build
  before_script:
    - apt-get update -y
    - apt-get -y install git zip unzip wget jq apt-transport-https ca-certificates gnupg python3 > /dev/null 2>&1
  script: if [ -z ${TEAM+x} ]; then echo teams/data/terraform/variables.tf | python3 python/generate-jobs.py > generated-config.yml; else find teams/${TEAM} | python3 python/generate-jobs.py > generated-config.yml; fi

  artifacts:
    paths:
      - generated-config.yml

validate-generated-config:
  stage: validate
  script: |
    if [ -s generated-config.yml ]; then
      echo "Child pipeline configuration found."
    else
      echo "No child pipeline configuration found, skipping child pipeline trigger."
      rm -f generated-config.yml
      touch skip-trigger  # Indicate to skip the trigger.
    fi
  artifacts:
    paths:
      - generated-config.yml
      - skip-trigger
  needs:
    - generate-config
  tags:
    - aws
    - prd

child-pipeline:
  stage: apply-tf
  trigger:
    include:
      - artifact: generated-config.yml
        job: generate-config
  needs:
    - validate-generated-config
  rules:
    - exists:
        - generated-config.yml
    - when: never
      exists:
        - skip-trigger