variables:
 GIT_SUBMODULE_STRATEGY: normal

image: danya25/asn1c:0.0.5

validate:
  stage: test
  script: make -f .gitlab-ci.mk validate
  only:
    changes:
      - "*.asn"

documentation:
  stage: deploy
  script:
    - >
      if ! [ -f asn2md.py ]; then
        curl -o asn2md.py --header "PRIVATE-TOKEN:$CI_JOB_TOKEN" "https://forge.etsi.org/rep/api/v4/projects/592/repository/files/asn2md.py/raw?ref=master"
      fi
    - make -f .gitlab-ci.mk doc
    - >
      git add docs/*.md
      if [ -z "$(git status --untracked-files=no --porcelain)" ]; then
        echo "No changes found"
      else 
        git commit -m "Documentation update" &&
        git remote rm origin && git remote add origin "https://${GITLAB_USER_LOGIN}:${CI_JOB_TOKEN}@forge.etsi.org/rep/$CI_PROJECT_PATH.git" &&
        git push origin "HEAD:$CI_COMMIT_REF_NAME";
      fi
  only:
    changes:
      - "*.asn"
