add docker files

This commit is contained in:
canguilieme julien 2024-10-07 22:12:10 +02:00
parent 0ab3c83eab
commit e20a92368e

View File

@ -26,7 +26,7 @@ deploy-job:
- deploiement
script:
- |
set -x
set -e
echo "Déploiement sur Portainer..."
echo "Utilisation du token API de Portainer..."
@ -34,26 +34,22 @@ deploy-job:
if [ -z "$PORTAINER_API_KEY" ]; then echo "Erreur : PORTAINER_API_KEY non définie."; exit 1; fi
if [ -z "$PORTAINER_URL" ]; then echo "Erreur : PORTAINER_URL non définie."; exit 1; fi
if [ -z "$STACK_ID" ]; then echo "Erreur : STACK_ID non définie."; exit 1; fi
if [ -z "$ENDPOINT_ID" ]; then echo "Erreur : ENDPOINT_ID non définie."; exit 1; fi
# Affichage des variables (sauf les sensibles)
echo "PORTAINER_URL : $PORTAINER_URL"
echo "STACK_ID : $STACK_ID"
echo "Déclenchement du redeploiement de la stack Git sur Portainer..."
echo "Déploiement de la stack sur Portainer..."
RESPONSE=$(curl -v -X PUT \
# Exécuter la requête pour redeployer la stack Git
RESPONSE=$(curl -s -k -w "%{http_code}" -X POST \
-H "Authorization: Bearer $PORTAINER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"Prune": true}' \
https://$PORTAINER_URL/api/stacks/$STACK_ID/deploy 2>&1)
"https://$PORTAINER_URL/api/stacks/$STACK_ID/git/redeploy?endpointId=$ENDPOINT_ID")
HTTP_CODE=$(echo "$RESPONSE" | grep "< HTTP/" | awk '{print $3}')
echo "Réponse de l'API :"
echo "$RESPONSE"
# Extraire le code HTTP de la réponse
HTTP_CODE="${RESPONSE: -3}"
BODY="${RESPONSE::-3}"
if [ "$HTTP_CODE" != "200" ]; then
echo "Erreur : Échec du déploiement. Code HTTP : $HTTP_CODE"
echo "Réponse de l'API : $BODY"
exit 1
fi