delete gitlab
This commit is contained in:
parent
8e4c000eaa
commit
252a63f469
@ -1,37 +0,0 @@
|
||||
stages:
|
||||
- deploy
|
||||
|
||||
deploy_to_portainer:
|
||||
stage: deploy
|
||||
image:
|
||||
name: curlimages/curl:latest
|
||||
entrypoint: [""]
|
||||
script:
|
||||
- echo "Installation de jq"
|
||||
- curl -L -o /usr/bin/jq https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64
|
||||
- chmod +x /usr/bin/jq
|
||||
- echo "Début du déploiement vers Portainer"
|
||||
- echo "Téléchargement du fichier docker-compose.yml depuis le dépôt"
|
||||
- 'curl -s -H "PRIVATE-TOKEN: $CI_JOB_TOKEN" -o docker-compose.yml "$CI_PROJECT_URL/raw/$CI_COMMIT_REF_NAME/docker-compose.yml"'
|
||||
- echo "Mise à jour ou création de la stack dans Portainer"
|
||||
- |
|
||||
STACK_ID=$(curl -s -H "Authorization: Bearer $PORTAINER_TOKEN" "$PORTAINER_URL/stacks?filters=%7B%22Name%22%3A%5B%22$STACK_NAME%22%5D%7D" | jq -r '.[0].Id')
|
||||
if [ "$STACK_ID" = "null" ] || [ -z "$STACK_ID" ]; then
|
||||
echo "La stack n'existe pas, création en cours"
|
||||
STACK_CREATE=$(curl -s -X POST "$PORTAINER_URL/stacks?type=1&method=string&endpointId=$ENDPOINT_ID" \
|
||||
-H "Authorization: Bearer $PORTAINER_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"Name\": \"$STACK_NAME\", \"StackFileContent\": \"$(cat docker-compose.yml | sed 's/\"/\\\"/g' | sed 's/$/\\n/' | tr -d '\n')\", \"Prune\": false}")
|
||||
echo "Réponse de création : $STACK_CREATE"
|
||||
else
|
||||
echo "La stack existe, mise à jour en cours"
|
||||
STACK_UPDATE=$(curl -s -X PUT "$PORTAINER_URL/stacks/$STACK_ID?endpointId=$ENDPOINT_ID" \
|
||||
-H "Authorization: Bearer $PORTAINER_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"StackFileContent\": \"$(cat docker-compose.yml | sed 's/\"/\\\"/g' | sed 's/$/\\n/' | tr -d '\n')\", \"Prune\": false, \"PullImage\": true}")
|
||||
echo "Réponse de mise à jour : $STACK_UPDATE"
|
||||
fi
|
||||
only:
|
||||
- main
|
||||
tags:
|
||||
- docker
|
||||
Loading…
Reference in New Issue
Block a user