mirror of
https://github.com/arthur-pbty/portfolio.git
synced 2026-08-01 20:29:43 +02:00
feat: ajouter un workflow GitHub Actions pour le déploiement en production
This commit is contained in:
@@ -0,0 +1,45 @@
|
|||||||
|
name: Deploy Production
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: production-deploy
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: self-hosted
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Deploy portfolio Production
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
echo "============================"
|
||||||
|
echo " Starting deployment"
|
||||||
|
echo "============================"
|
||||||
|
|
||||||
|
APP_DIR="/srv/apps/portfolio"
|
||||||
|
|
||||||
|
cd "$APP_DIR"
|
||||||
|
|
||||||
|
echo "Fetching latest code..."
|
||||||
|
git fetch origin main
|
||||||
|
|
||||||
|
echo "Resetting local state..."
|
||||||
|
git reset --hard origin/main
|
||||||
|
|
||||||
|
echo "Cleaning untracked files (keeping .env)"
|
||||||
|
git clean -fd -e .env
|
||||||
|
|
||||||
|
echo "Pulling/building containers..."
|
||||||
|
docker compose pull || true
|
||||||
|
docker compose up -d --build --remove-orphans
|
||||||
|
|
||||||
|
echo "Cleaning unused Docker images..."
|
||||||
|
docker image prune -f
|
||||||
|
|
||||||
|
echo "Deployment finished successfully"
|
||||||
Reference in New Issue
Block a user