Compare commits
8 Commits
38a2e08062
...
f2b6782e5c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f2b6782e5c | ||
|
|
52307782a7 | ||
|
|
5a54940424 | ||
|
|
ce8a1049dd | ||
|
|
9c511c0619 | ||
|
|
9a79777e34 | ||
|
|
d65cb721b5 | ||
|
|
b7f85c9bf9 |
44
.gitea/actions/notify-security-failure/action.yml
Normal file
44
.gitea/actions/notify-security-failure/action.yml
Normal file
@ -0,0 +1,44 @@
|
||||
name: Notify security gate failure
|
||||
description: Posts a Discord alert when the Security gate fails and stops the pipeline.
|
||||
inputs:
|
||||
webhook-url:
|
||||
description: Discord webhook URL.
|
||||
required: true
|
||||
pipeline:
|
||||
description: Human-readable pipeline name shown in the alert.
|
||||
required: true
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Discord
|
||||
shell: bash
|
||||
env:
|
||||
WEBHOOK_URL: ${{ inputs.webhook-url }}
|
||||
PIPELINE: ${{ inputs.pipeline }}
|
||||
REF_NAME: ${{ github.ref_name }}
|
||||
ACTOR: ${{ github.actor }}
|
||||
SHA: ${{ github.sha }}
|
||||
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
||||
run: |
|
||||
# Payload built with json.dumps: branch or author names cannot break the JSON.
|
||||
payload=$(python3 - <<'PY'
|
||||
import json, os
|
||||
print(json.dumps({
|
||||
"content": "@here Security gate en échec — pipeline arrêté",
|
||||
"embeds": [{
|
||||
"title": f"🔒 Security gate en échec — {os.environ['PIPELINE']}",
|
||||
"description": "Aucun lint, test, build ni déploiement n'a été lancé. Consultez l'artefact `security-reports`.",
|
||||
"color": 15158332,
|
||||
"fields": [
|
||||
{"name": "Branche", "value": f"`{os.environ['REF_NAME']}`", "inline": True},
|
||||
{"name": "Auteur", "value": os.environ["ACTOR"], "inline": True},
|
||||
{"name": "Commit", "value": f"`{os.environ['SHA'][:7]}`", "inline": True},
|
||||
{"name": "Workflow", "value": f"[Voir le run]({os.environ['RUN_URL']})", "inline": False},
|
||||
],
|
||||
"footer": {"text": f"Xpeditis CI/CD • {os.environ['PIPELINE']}"},
|
||||
}],
|
||||
}))
|
||||
PY
|
||||
)
|
||||
curl -fsS --max-time 15 -H "Content-Type: application/json" -d "$payload" "$WEBHOOK_URL" \
|
||||
|| echo "::warning::Notification Discord non envoyée."
|
||||
@ -2,7 +2,7 @@ name: CD Production
|
||||
|
||||
# Pipeline de production — Hetzner k3s (infra/prod/).
|
||||
#
|
||||
# Enchaînement : qualité → vérification → promotion/rebuild → déploiement → contrôle
|
||||
# Enchaînement : sécurité → qualité → vérification → promotion/rebuild → déploiement → contrôle
|
||||
#
|
||||
# TROIS RÈGLES STRUCTURANTES
|
||||
#
|
||||
@ -66,11 +66,18 @@ jobs:
|
||||
path: ${{ runner.temp }}/security-reports/*.json
|
||||
retention-days: 7
|
||||
if-no-files-found: error
|
||||
- name: Notify Discord
|
||||
if: failure()
|
||||
uses: ./.gitea/actions/notify-security-failure
|
||||
with:
|
||||
webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
|
||||
pipeline: Production
|
||||
|
||||
# ═══ 1. Qualité ══════════════════════════════════════════════════════════
|
||||
backend-quality:
|
||||
name: Backend — Lint
|
||||
runs-on: ubuntu-latest
|
||||
needs: security
|
||||
defaults:
|
||||
run:
|
||||
working-directory: apps/backend
|
||||
@ -85,6 +92,7 @@ jobs:
|
||||
frontend-quality:
|
||||
name: Frontend — Lint & Type-check
|
||||
runs-on: ubuntu-latest
|
||||
needs: security
|
||||
defaults:
|
||||
run:
|
||||
working-directory: apps/frontend
|
||||
@ -386,7 +394,8 @@ jobs:
|
||||
name: Notifier l'échec
|
||||
runs-on: ubuntu-latest
|
||||
needs: [security, backend-quality, frontend-quality, backend-tests, frontend-tests, verify-image, build-frontend, image-security, deploy]
|
||||
if: failure()
|
||||
# Security gate failures are already reported by the security job itself.
|
||||
if: failure() && needs.security.result != 'failure'
|
||||
steps:
|
||||
- run: |
|
||||
curl -sf -H "Content-Type: application/json" -d '{
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
name: CD Preprod
|
||||
|
||||
# Full pipeline triggered on every push to preprod.
|
||||
# Flow: lint → unit tests → integration tests → docker build → deploy → notify
|
||||
# Flow: security gate → lint → unit tests → integration tests → docker build → deploy → notify
|
||||
#
|
||||
# Secrets required:
|
||||
# REGISTRY_TOKEN — Scaleway registry (read/write)
|
||||
@ -55,11 +55,18 @@ jobs:
|
||||
path: ${{ runner.temp }}/security-reports/*.json
|
||||
retention-days: 7
|
||||
if-no-files-found: error
|
||||
- name: Notify Discord
|
||||
if: failure()
|
||||
uses: ./.gitea/actions/notify-security-failure
|
||||
with:
|
||||
webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
|
||||
pipeline: Preprod
|
||||
|
||||
# ── 1. Lint ─────────────────────────────────────────────────────────
|
||||
backend-quality:
|
||||
name: Backend — Lint
|
||||
runs-on: ubuntu-latest
|
||||
needs: security
|
||||
defaults:
|
||||
run:
|
||||
working-directory: apps/backend
|
||||
@ -74,6 +81,7 @@ jobs:
|
||||
frontend-quality:
|
||||
name: Frontend — Lint & Type-check
|
||||
runs-on: ubuntu-latest
|
||||
needs: security
|
||||
defaults:
|
||||
run:
|
||||
working-directory: apps/frontend
|
||||
@ -425,7 +433,8 @@ jobs:
|
||||
name: Notify Failure
|
||||
runs-on: ubuntu-latest
|
||||
needs: [security, backend-quality, frontend-quality, backend-tests, frontend-tests, integration-tests, build-backend, build-frontend, build-log-exporter, image-security, deploy]
|
||||
if: failure()
|
||||
# Security gate failures are already reported by the security job itself.
|
||||
if: failure() && needs.security.result != 'failure'
|
||||
steps:
|
||||
- run: |
|
||||
curl -s -H "Content-Type: application/json" -d '{
|
||||
|
||||
@ -40,10 +40,17 @@ jobs:
|
||||
path: ${{ runner.temp }}/security-reports/*.json
|
||||
retention-days: 7
|
||||
if-no-files-found: error
|
||||
- name: Notify Discord
|
||||
if: failure()
|
||||
uses: ./.gitea/actions/notify-security-failure
|
||||
with:
|
||||
webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
|
||||
pipeline: Dev
|
||||
|
||||
backend-quality:
|
||||
name: Backend — Lint
|
||||
runs-on: ubuntu-latest
|
||||
needs: security
|
||||
defaults:
|
||||
run:
|
||||
working-directory: apps/backend
|
||||
@ -58,6 +65,7 @@ jobs:
|
||||
frontend-quality:
|
||||
name: Frontend — Lint & Type-check
|
||||
runs-on: ubuntu-latest
|
||||
needs: security
|
||||
defaults:
|
||||
run:
|
||||
working-directory: apps/frontend
|
||||
@ -104,7 +112,8 @@ jobs:
|
||||
name: Notify Failure
|
||||
runs-on: ubuntu-latest
|
||||
needs: [security, backend-quality, frontend-quality, backend-tests, frontend-tests]
|
||||
if: failure()
|
||||
# Security gate failures are already reported by the security job itself.
|
||||
if: failure() && needs.security.result != 'failure'
|
||||
steps:
|
||||
- name: Discord
|
||||
run: |
|
||||
|
||||
@ -42,10 +42,17 @@ jobs:
|
||||
path: ${{ runner.temp }}/security-reports/*.json
|
||||
retention-days: 7
|
||||
if-no-files-found: error
|
||||
- name: Notify Discord
|
||||
if: failure()
|
||||
uses: ./.gitea/actions/notify-security-failure
|
||||
with:
|
||||
webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
|
||||
pipeline: PR Checks
|
||||
|
||||
backend-quality:
|
||||
name: Backend — Lint
|
||||
runs-on: ubuntu-latest
|
||||
needs: security
|
||||
defaults:
|
||||
run:
|
||||
working-directory: apps/backend
|
||||
@ -60,6 +67,7 @@ jobs:
|
||||
frontend-quality:
|
||||
name: Frontend — Lint & Type-check
|
||||
runs-on: ubuntu-latest
|
||||
needs: security
|
||||
defaults:
|
||||
run:
|
||||
working-directory: apps/frontend
|
||||
|
||||
Loading…
Reference in New Issue
Block a user