workflow:
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
    - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
      when: never
    - if: $CI_COMMIT_BRANCH

stages:
  - preflight
  - check
  - build

preflight:
  image: "forge.etsi.org:5050/li/schemas-definitions/forgelib"
  stage: preflight
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
  interruptible: true
  script:
    - forgelib-preflight https://$CI_SERVER_HOST $CI_PROJECT_ID $CI_MERGE_REQUEST_IID

process_asn:
  image: "forge.etsi.org:5050/li/schemas-definitions/asn1test:latest"
  stage: check
  interruptible: true
  script:
    - python3 testing/asn_process.py

process_xsd:
  image: "forge.etsi.org:5050/li/schemas-definitions/xsdtest:latest"
  stage: check
  interruptible: true
  script:
    - python3 testing/xsd_process.py

generate_artefacts:
  image: "forge.etsi.org:5050/li/schemas-definitions/forgelib"
  stage: build
  interruptible: true
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
  script:
    - echo $CI_PROJECT_ID
    - echo $CI_PROJECT_NAME
    - echo $CI_PROJECT_PATH
    - echo $CI_PIPELINE_SOURCE
    - echo $CI_OPEN_MERGE_REQUESTS
    - echo $CI_MERGE_REQUEST_IID
    - echo $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
    - echo $ARTEFACT_NAME
    - forgelib-changedocs -v -d -c -l --startdelimiter coversheets/delimiter_start.docx --enddelimiter coversheets/delimiter_end.docx https://$CI_SERVER_HOST/rep $CI_PROJECT_ID $CI_PROJECT_PATH $CI_MERGE_REQUEST_IID
  artifacts:
    untracked: true
    paths:
      - "*.docx"
    name: $CI_MERGE_REQUEST_TITLE
    expire_in: 30 days
