Skip to content
Snippets Groups Projects
Commit 3b17f99e authored by Mathias Chouet's avatar Mathias Chouet
Browse files

Fix #374 - add stale brancehs/tags removal

parent 707df60c
No related branches found
No related tags found
No related merge requests found
......@@ -76,6 +76,17 @@ build:
script:
- npm run build -- --base-href=/cassiopee/$CI_COMMIT_REF_NAME/
clean-stale-branches:
stage:
- deploy
- deploy-stable
only:
- pushes
- tags
- web
script:
- nodejs scripts/remove-stale-branches.sh $DEPLOY_HOST_LOGIN $DEPLOY_URL
deploy:
stage: deploy
only:
......
......@@ -51,7 +51,7 @@ rm "./$TMP_RELEASES_FILE"
scp "release/Cassiopée Setup $VERSION.exe" "release/fr.irstea.cassiopee_${VERSION}_amd64.deb" "release/cassiopee-$VERSION.apk" "release/Cassiopée-${VERSION}-mac.zip" "$HOST_LOGIN:$RELEASES_DIR/"
# symlink "latest" version for each platform
ssh $HOST_LOGIN /bin/bash << "EOF"
ssh $HOST_LOGIN /bin/bash << EOF
cd "$RELEASES_DIR"
ln -sf "Cassiopée Setup $VERSION.exe" "windows-latest.exe"
ln -sf "fr.irstea.cassiopee_${VERSION}_amd64.deb" "linux-latest.deb"
......
#!/bin/bash
# Supprime du serveur Web les "builds" de Cassiopée correspondant à des branches ou des
# tags qui n'existent plus dans le dépôt.
# Conçu pour être utilisé par Gitlab CI/CD
if [ "$#" -lt 2 ]; then
echo "usage: $0 login@server /var/www/deploy_dir"
exit 1
fi
HOST_LOGIN="$1"
DEPLOY_DIR="$2"
# DEPLOY_DIR="/tmp/cassiopee" # debug
echo "remove-stale-branches.sh: cleaning directory $DEPLOY_DIR on host $HOST_LOGIN"
nghyd_branches=$(git ls-remote --heads origin|awk '{print $2}'|awk 'BEGIN{FS="/"} {print $3}')
nghyd_tags=$(git tag)
TNB="$nghyd_branches $nghyd_tags"
ssh $HOST_LOGIN /bin/bash << EOF
cd $DEPLOY_DIR
LOCALTNB="$TNB"
for d in \$(ls -d *); do
found=0
for tag_or_branch in \$LOCALTNB; do
if [[ \$d == \$tag_or_branch ]]; then
found=1
break
fi
done
if (( \$found == 0 )); then
echo "suppression de branche/tag obsolète \$d"
rm -rf \$d
fi
done
EOF
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment