feat: ci/cd
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
name: CD
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows:
|
||||
- CI
|
||||
branches:
|
||||
- main
|
||||
types:
|
||||
- completed
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
name: Déploiement production
|
||||
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Configuration SSH
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
echo "${{ secrets.DEPLOY_SSH_KEY }}" \
|
||||
> ~/.ssh/id_ed25519
|
||||
chmod 600 ~/.ssh/id_ed25519
|
||||
|
||||
ssh-keyscan \
|
||||
-H "${{ secrets.DEPLOY_HOST }}" \
|
||||
>> ~/.ssh/known_hosts
|
||||
|
||||
- name: 🚀 Deploy Docker
|
||||
run: |
|
||||
ssh \
|
||||
-i ~/.ssh/id_ed25519 \
|
||||
${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }} << 'EOF'
|
||||
set -e
|
||||
|
||||
echo "Projet"
|
||||
cd /data/docker/landing-web
|
||||
|
||||
echo "Pull nouvelle image"
|
||||
docker compose pull
|
||||
|
||||
echo "Redémarrage"
|
||||
docker compose up -d
|
||||
|
||||
EOF
|
||||
@@ -0,0 +1,65 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- develop
|
||||
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
name: 🔍 Lint & Type Check
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 📥 Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: 🟢 Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '22'
|
||||
|
||||
- name: 📦 Cache node_modules
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.npm
|
||||
key: npm-${{ hashFiles('package-lock.json') }}
|
||||
restore-keys: |
|
||||
npm-
|
||||
|
||||
- name: 📥 Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: 🔍 Lint
|
||||
run: npm run lint
|
||||
|
||||
docker:
|
||||
name: 🐳 Build & Push Image
|
||||
needs: lint
|
||||
if: ${{ github.ref == 'refs/heads/main' }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 📥 Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: 🔐 Login Registry Gitea
|
||||
run: |
|
||||
docker login git.leonmorival.xyz \
|
||||
-u "${{ secrets.REGISTRY_USER }}" \
|
||||
-p "${{ secrets.REGISTRY_PASSWORD }}"
|
||||
|
||||
- name: 🏗️ Build image
|
||||
run: |
|
||||
docker build \
|
||||
-t git.leonmorival.xyz/leonm/landing-server:latest \
|
||||
-t git.leonmorival.xyz/leonm/landing-server:${{ github.sha }} \
|
||||
.
|
||||
|
||||
- name: 📤 Push image
|
||||
run: |
|
||||
docker push git.leonmorival.xyz/leonm/landing-server:latest
|
||||
docker push git.leonmorival.xyz/leonm/landing-server:${{ github.sha }}
|
||||
Reference in New Issue
Block a user