From e2d6f51fa0cfac0ee435ab9d96f1eea1df548bb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Vallv=C3=A9=20Navarro?= <jvallve@iri.upc.edu> Date: Fri, 19 Nov 2021 15:50:55 +0100 Subject: [PATCH] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1e3fd8d3f..339dbb696 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,6 +20,37 @@ # update apt - apt-get update +.license_header_template: &license_header_definition + + - echo $PWD + - exit 1 + + # LICENSE MANAGEMENT + - echo "current year of the headers: ${LICENSE_HEADER_YEAR}" + - export LICENSE_HEADER_YEAR_NEW=$( date +'%Y' ) + # UPDATE: check if license headers have to be updated + - if [ ! ${LICENSE_HEADER_YEAR} == ${LICENSE_HEADER_YEAR_NEW} ] + - echo "license headers should be changed!" + - echo "Creating new file wolf_scripts/license_header_${LICENSE_HEADER_YEAR_NEW}.txt..." + - cd wolf_scripts + - cp license_header_${LICENSE_HEADER_YEAR}.txt license_header_${LICENSE_HEADER_YEAR_NEW}.txt + - sed -e "s/${LICENSE_HEADER_YEAR}/'${LICENSE_HEADER_YEAR},${LICENSE_HEADER_YEAR_NEW}'/g" license_header_${LICENSE_HEADER_YEAR_NEW}.txt + - ./license_manager.sh --update --path=${HOME}/???? --license-header=license_header_${LICENSE_HEADER_YEAR_NEW}.txt + # ADD: add license headers + - else + - ./license_manager.sh --add --path=${HOME}/???? --license-header=license_header_${LICENSE_HEADER_YEAR}.txt + - fi + + # push changes (if any) + - git config --global user.email "${CI_EMAIL}" + - git config --global user.name "${CI_USERNAME}" + - if git commit -m "license headers added or modified" ; then + - git remote set-url --push origin "ssh://git@gitlab.iri.upc.edu:2202/${CI_PROJECT_PATH}.git" + - git push origin HEAD:${CI_COMMIT_REF_NAME} + - else + - echo "No changes, nothing to commit!" + - fi + .build_and_test_template: &build_and_test_definition - mkdir -pv build - cd build @@ -52,9 +83,6 @@ license_header: - git commit -m "added prova.txt" || echo "No changes, nothing to commit!" - git remote set-url --push origin "ssh://git@gitlab.iri.upc.edu:2202/${CI_PROJECT_PATH}.git" - - # push changes - # always return true so that the build does not fail if there are no changes - git push origin HEAD:${CI_COMMIT_REF_NAME} build_and_test:xenial: -- GitLab