demo/.drone.yml
supercodeur bac67b7d68
All checks were successful
continuous-integration/drone/push Build is passing
Actualiser .drone.yml
2025-05-29 12:16:21 +02:00

129 lines
5.0 KiB
YAML

kind: pipeline
type: docker
name: deploy-project
steps:
- name: deploy public_html
image: alpine:3.20
volumes:
- name: ididit
path: /var/www/ididit
commands:
- |
if [ -d public_html ] && [ "$(ls -A public_html)" ]; then
target="/var/www/ididit/${DRONE_REPO_OWNER}/${DRONE_REPO_NAME}"
echo "Déploiement vers $target"
rm -rf "$target"
mkdir -p "$target"
cp -r public_html/* "$target/"
echo "Déploiement terminé."
ls -alh "$target"
else
echo "Aucun dossier public_html à déployer."
fi
when:
branch:
- main
event:
- push
- name: build-web
image: ghcr.io/cirruslabs/flutter:latest
volumes:
- name: ididit
path: /var/www/ididit
commands:
- apt-get update && apt-get install -y tar
- VERSION=$(grep '^version:' pubspec.yaml | awk '{print $2}')
- |
if [ -d web ]; then
echo "Build Web..."
flutter pub get
flutter build web --release
TARGET="/var/www/ididit/$DRONE_REPO_OWNER/$DRONE_REPO_NAME/releases/$VERSION/web"
mkdir -p "$TARGET"
tar czf "$TARGET/web-$VERSION.tgz" -C build/web .
echo "Web bundle published as $TARGET/web-$VERSION.tgz"
else
echo "No web/ directory, skipping."
fi
- name: generate-versions-html
image: alpine:3.20
volumes:
- name: ididit
path: /var/www/ididit
commands:
- OWNER="$DRONE_REPO_OWNER"
- REPO="$DRONE_REPO_NAME"
- RELEASES_DIR="/var/www/ididit/$OWNER/$REPO/releases"
- REPO_URL="https://gitea.bymycode.com/$OWNER/$REPO"
- |
HTML="$RELEASES_DIR/index.html"
echo '<!DOCTYPE html>' > "$HTML"
echo '<html lang="fr">' >> "$HTML"
echo '<head>' >> "$HTML"
echo ' <meta charset="UTF-8">' >> "$HTML"
echo " <title>Versions disponibles pour $REPO</title>" >> "$HTML"
echo ' <style>' >> "$HTML"
echo ' body { font-family: sans-serif; background: #f7f7f7; color: #222; margin: 2em; }' >> "$HTML"
echo ' h1 { color: #346beb; }' >> "$HTML"
echo ' h2 { margin-top: 2em; }' >> "$HTML"
echo ' ul { list-style: none; padding: 0; }' >> "$HTML"
echo ' li { margin: 0.5em 0; }' >> "$HTML"
echo ' a { color: #346beb; text-decoration: none; font-weight: bold; }' >> "$HTML"
echo ' .repo { margin-top: 2em; font-size: 0.95em; }' >> "$HTML"
echo ' .icon { margin-right: 0.5em; }' >> "$HTML"
echo ' </style>' >> "$HTML"
echo '</head>' >> "$HTML"
echo '<body>' >> "$HTML"
echo " <h1>Versions disponibles pour <span style=\"color:#346beb;\">$REPO</span></h1>" >> "$HTML"
echo " <div class=\"repo\">" >> "$HTML"
echo " 📦 <a href=\"$REPO_URL\">Voir le repository sur gitea.ByMyCode.com</a>" >> "$HTML"
echo " </div>" >> "$HTML"
echo " <hr>" >> "$HTML"
for version_dir in $(ls -1 "$RELEASES_DIR" | sort -Vr); do
if [ -d "$RELEASES_DIR/$version_dir" ]; then
echo "<h2>Version $version_dir</h2>" >> "$HTML"
# Linux bundle
if [ -f "$RELEASES_DIR/$version_dir/linux/linux-$version_dir.tgz" ]; then
echo "<ul><li><strong>Linux :</strong></li>" >> "$HTML"
echo "<li><span class='icon'>🐧</span><a href=\"./$version_dir/linux/linux-$version_dir.tgz\">linux-$version_dir.tgz</a></li>" >> "$HTML"
echo "</ul>" >> "$HTML"
fi
# Android
if [ -d "$RELEASES_DIR/$version_dir/android" ]; then
for f in "$RELEASES_DIR/$version_dir/android/"*; do
fname=$(basename "$f")
echo "<ul><li><strong>Android :</strong></li>" >> "$HTML"
echo "<li><span class='icon'>🤖</span><a href=\"./$version_dir/android/$fname\">$fname</a></li>" >> "$HTML"
echo "</ul>" >> "$HTML"
done
fi
# Web bundle
if [ -f "$RELEASES_DIR/$version_dir/web/web-$version_dir.tgz" ]; then
echo "<ul><li><strong>Web :</strong></li>" >> "$HTML"
echo "<li><span class='icon'>🌍</span><a href=\"./$version_dir/web/web-$version_dir.tgz\">web-$version_dir.tgz</a></li>" >> "$HTML"
echo "</ul>" >> "$HTML"
fi
echo "<hr>" >> "$HTML"
fi
done
echo "<footer style='margin-top:2em;font-size:0.9em;color:#888;'>Généré automatiquement par ByMyCode.com CI 🚀</footer>" >> "$HTML"
echo "</body>" >> "$HTML"
echo "</html>" >> "$HTML"
echo "Fichier versions.html généré dans $HTML"
- name: list-published
image: alpine:3.20
volumes:
- name: ididit
path: /var/www/ididit
commands:
- ls -alR /var/www/ididit/$DRONE_REPO_OWNER/$DRONE_REPO_NAME/releases || echo "No releases published."
volumes:
- name: ididit
host:
path: /var/www/ididit