From 9c97901275e742bb70bc1a9ed14f1366b3ed3fb1 Mon Sep 17 00:00:00 2001 From: Alexandre CHAZAL Date: Thu, 25 May 2023 16:21:04 +0200 Subject: [PATCH] feat(gitlab): add ci to automatically update parent project --- .gitlab-ci.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..34c2d48 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,27 @@ +trigger: + stage: trigger + image: quay.io/curl/curl:latest + script: + # Put the private-token with a colon into a variable to escape the "Linefeed-Limbo" (https://stackoverflow.com/a/51187502) + - PRIVATE_TOKEN="${PRIVATE_TOKEN}:" + + # Get the current datetime (in local time with the TZ variable) + - CURRENT_DATE="$(date +'%F %T')" + + # Add it to each commit message of the repository (and make sure there is no carriage returns) + - MESSAGE="${COMMIT_MESSAGE:-$CI_COMMIT_MESSAGE} (${CURRENT_DATE})" + - MESSAGE=$(echo "${MESSAGE}"|tr -d '\n') + + # Use the Repository submodules API to update the submodule reference in the repository + - curl + --data "branch=${BRANCH:-$CI_DEFAULT_BRANCH}&commit_sha=${COMMIT_SHA:-$CI_COMMIT_SHA}&commit_message=${MESSAGE}" + --header "${PRIVATE_TOKEN} ${GITLAB_TOKEN}" + --request PUT + "${CI_SERVER_URL}/api/v4/projects/${PROJECT_ID}/repository/submodules/${SUBMODULE_PATH}" + rules: + - changes: + - post/ + variables: + PROJECT_ID: '8' + SUBMODULE_PATH: 'content' + TZ: ':Europe/Paris