Newer
Older
variables:
SERVER:
WEBUI:
MYSQL:
PYLIB:
script:
- echo "SERVER=$SERVER"
- echo "WEBUI=$WEBUI"
- echo "PYLIB=$PYLIB"
- echo "MYSQL=$MYSQL"
- if: $CI_PIPELINE_SOURCE == "pipeline"
- if: $CI_PIPELINE_SOURCE == "web"
stage: commit
before_script:
- apk add curl
script:
- test -z "$CIPRIVATETOKEN" && echo "CIPRIVATETOKEN variable was empty" && exit 1;
- test -z "$SERVER" && echo "SERVER variable was empty" && exit 1;
# delete last line (array closing bracket ']')
- sed -i '$d' versions.json
# add new record
- echo ",{\"server\"${COLON} \"$SERVER\", \"mysqlbackend\"${COLON} \"$MYSQL\", \"pylib\"${COLON} \"$PYLIB\", \"webui\"${COLON} \"$WEBUI\" }" >> versions.json
# add closing ] again
- echo "\n]"
# create the commit.json which is to send to the commit api of gitlab
- echo -n "{\"branch\"${COLON} \"main\", \"commit_message\"${COLON} \"new commit via ci pipeline\", \"actions\"${COLON} [ { \"action\"${COLON} \"update\", \"file_path\"${COLON} \"versions.json\", \"encoding\"${COLON} \"base64\", \"content\"${COLON} \"" > commit.json
- echo -n "$(base64 versions.json)" >> commit.json
# commit the changes (which then triggers the pages job)
- curl --fail-with-body --request POST --header "PRIVATE-TOKEN${COLON} $CIPRIVATETOKEN" --header "Content-Type${COLON} application/json" --data "$(cat commit.json)" "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/repository/commits"
- cp versions.json public/
- echo '<a href="versions.json">versions.json</a>' > public/index.html