variables:
  # base image used to extract the shell script part from TBC templates
  TBC_EXTRACT_IMAGE: registry.hub.docker.com/library/alpine

# this job extracts the bash script from the given template(s)
extract-script:
  image: $TBC_EXTRACT_IMAGE
  stage: .pre
  script:
    - echo "#!/bin/bash" > script.sh
    - sed -n '/BEGSCRIPT/,/ENDSCRIPT/p' "$GITLAB_CI_FILES" | sed 's/^  //' >> script.sh
    - export LC_ALL=C.UTF-8
  artifacts:
    when: always
    name: extracted template script
    expire_in: 1h
    paths:
      - script.sh
  rules:
    # enabled if $GITLAB_CI_FILES is set
    - if: $GITLAB_CI_FILES