I have a YAML file ( GitLab-ci.yml )
deploy-perf:
  extends: .deploy-np
  environment:
    name: perf
  variables:
    APP_NAME: $APP_NAME_PERF
    PCF_MF_FILE: 'manifest.perf.yml'
  rules:
    - if: '$CI_COMMIT_BRANCH =~ /^([fF]eature|[rR]elease).*$/'
validate-ci:
  extends: .healthcheck-v1
  variables:
    HEALTH_CHECK_URL: "https://[URL]/index.html"
  rules:
    - if: '$CI_COMMIT_BRANCH =~ /^([fF]eature).*$/'
validate-g1:
  extends: .healthcheck-v1
  variables:
    HEALTH_CHECK_URL: "https://[URL]/index.html"
  rules:
    - if: '$CI_COMMIT_BRANCH =~ /^([fF]eature).*$/'
I want to insert the below text or job in the above file at the position above 'validate-ci:' line
deploy-PROD:
  extends: .deploy-PROD
  environment:
    name: prod
  variables:
    APP_NAME: $APP_NAME_PROD
    PCF_MF_FILE: 'manifest.perf.yml'
  rules:
    - if: '$CI_COMMIT_BRANCH =~ /^([fF]eature|[rR]elease).*$/'
I am trying with sed but the indentation is not coming up accurately.
sed -re '/validate-ci,*/i'"`echo $MYVAR`" cifile.yml
or
sed -re '/validate-ci,*/i'"`cat prodjob.yml`" cifile.yml
If somebody could help me with this is much appreciated
I am fine if accomplished with python or bash and sed/awk combinations.
 
     
    