Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

feat: beta branding #238

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .env.development
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
NEXT_TELEMETRY_DISABLED=1
NEXT_PUBLIC_SITE_URL=""
NEXT_PUBLIC_SENTRY_DSN="https://[email protected]/68"
NEXT_PUBLIC_SENTRY_DSN="https://xxx/yy"
NEXT_PUBLIC_SENTRY_ENV="dev"
NEXT_PUBLIC_MATOMO_URL=""
NEXT_PUBLIC_MATOMO_SITE_ID=""
NEXT_PUBLIC_APP_REPOSITORY_URL="https://github.com/SocialGouv/template"
NEXT_PUBLIC_APP_REPOSITORY_URL="https://github.com/betagouv/template"
9 changes: 5 additions & 4 deletions .env.production
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
NEXT_TELEMETRY_DISABLED=1
NEXT_PUBLIC_SITE_URL="https://template.fabrique.social.gouv.fr/"
NEXT_PUBLIC_SENTRY_DSN="https://[email protected]/68"
NEXT_PUBLIC_SITE_URL="https://template.beta.gouv.fr/"
NEXT_PUBLIC_SENTRY_DSN="https://xxx/yy"
NEXT_PUBLIC_SENTRY_ENV="production"
NEXT_PUBLIC_MATOMO_URL="https://matomo.fabrique.social.gouv.fr"
NEXT_PUBLIC_MATOMO_URL="https:/stats.beta.gouv.fr"
NEXT_PUBLIC_MATOMO_SITE_ID=63
NEXT_PUBLIC_APP_REPOSITORY_URL="https://github.com/SocialGouv/template"
NEXT_PUBLIC_APP_REPOSITORY_URL="https://github.com/betagouv/template"
PRODUCTION=true
8 changes: 4 additions & 4 deletions .env.staging
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
NEXT_TELEMETRY_DISABLED=1
NEXT_PUBLIC_SITE_URL="https://template.fabrique.social.gouv.fr/"
NEXT_PUBLIC_SENTRY_DSN="https://[email protected]/68"
NEXT_PUBLIC_SENTRY_ENV="development"
NEXT_PUBLIC_SITE_URL="https://template.incubateur.net/"
NEXT_PUBLIC_SENTRY_DSN="https://xxx/yy"
NEXT_PUBLIC_SENTRY_ENV="staging"
NEXT_PUBLIC_MATOMO_URL=""
NEXT_PUBLIC_MATOMO_SITE_ID=""
NEXT_PUBLIC_APP_REPOSITORY_URL="https://github.com/SocialGouv/template"
NEXT_PUBLIC_APP_REPOSITORY_URL="https://github.com/betagouv/template"
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"next/core-web-vitals",
"plugin:storybook/recommended",
"plugin:jsx-a11y/recommended"
]
],
"rules": { "react/no-unescaped-entities": "warn" }
}
23 changes: 0 additions & 23 deletions .github/workflows/deactivate.yaml

This file was deleted.

22 changes: 0 additions & 22 deletions .github/workflows/debug-kube.yaml

This file was deleted.

24 changes: 14 additions & 10 deletions .github/workflows/storybook.yml → .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: Storybook
name: Deploy demo

on:
push:
branches: [main]
branches: [main, next]

concurrency:
cancel-in-progress: true
group: storybook-${{ github.ref }}
group: deploy-${{ github.ref }}

jobs:
storybook:
name: Deployment storybook on gh-pages
build:
name: Deployment demo on gh-pages
runs-on: ubuntu-latest
steps:
- name: Checkout repository
Expand All @@ -26,9 +26,13 @@ jobs:
run: |
yarn --immutable

- name: Deploy
- name: Build
run: |
git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
yarn storybook:deploy:action
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
yarn build

# deploy build to gh-pages
- name: Deploy 🚀
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: out
6 changes: 1 addition & 5 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ jobs:
uses: cypress-io/github-action@v5
with:
build: yarn build
start: yarn start
start: npx serve@latest out
component: false
install-command: yarn --immutable
env:
NEXTAUTH_URL: "http://keycloak:3000"
NEXTAUTH_SECRET: "A+EQqudlGhqTLDnBbCvohHBfbhUjTXAbZYy1NKsSsys="
NEXT_PUBLIC_HASURA_GRAPHQL_ENDPOINT_URL: "http://hasura:8082/v1/graphql"
19 changes: 0 additions & 19 deletions .github/workflows/preproduction.yaml

This file was deleted.

16 changes: 0 additions & 16 deletions .github/workflows/production.yaml

This file was deleted.

4 changes: 1 addition & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,4 @@ jobs:
steps:
- uses: socialgouv/workflows/actions/semantic-release@v1
with:
github-token: ${{ secrets.SOCIALGROOVYBOT_BOTO_PAT }}
author-name: ${{ secrets.SOCIALGROOVYBOT_NAME }}
author-email: ${{ secrets.SOCIALGROOVYBOT_EMAIL }}
github-token: ${{ secrets.GITHUB_TOKEN }}
16 changes: 0 additions & 16 deletions .github/workflows/review-auto.yaml

This file was deleted.

19 changes: 0 additions & 19 deletions .github/workflows/review.yaml

This file was deleted.

9 changes: 5 additions & 4 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint-staged
exec < /dev/tty; yarn node-talisman --githook pre-commit -i
if sh -c ': >/dev/tty' >/dev/null 2>/dev/null; then
exec </dev/tty; yarn node-talisman --githook pre-commit -i;
else
yarn node-talisman --githook pre-commit;
fi
10 changes: 9 additions & 1 deletion .talismanrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
fileignoreconfig:
- filename: .env.development
checksum: 44d017f8bd7ac1f3f4fb8b8175b3dddb6f160cf05b2738ec16b5b848aeb62d3f
checksum: f883cd5c4caa0fd48b4c2d995fc352b3d6d51dfa9d1d1eff7dabc27ef6209b3b
- filename: .env.production
checksum: b0bed73a6579de408405809f6bb0f724ac9a395b66fa182e39692be4bfd3697a
- filename: .env.staging
checksum: 4edc189842e797a550ecb727c5792e810ec68d419fa22b4cc26a4f441aa62793
- filename: .github/workflows/build.yml
checksum: c2eaa7d33f20ce615a65740718a652474e5fe4ad0437374ca671bd73317cdd95
- filename: .github/workflows/e2e.yml
Expand All @@ -21,6 +25,10 @@ fileignoreconfig:
checksum: 7c55475ff28dbfa46c9c5715918add6a0202eafddca3cf9d35ebcdd443d76ffd
- filename: pages/mui.tsx
checksum: 65dd6ab0469f43924ffc92d26055de14a77b1ef873e0efe69a014b582c38b694
- filename: src/pages/404.tsx
checksum: 96dab70b40d454f6d746ebd1c300f491ca82744cf52f3c0a3e05a039513cc4c1
- filename: src/pages/500.tsx
checksum: 0304444e184bbaca79130a05014bbbc9434958bc89a23d1af59ec8cdceba2f4c
scopeconfig:
- scope: node
version: "1.0"
90 changes: 4 additions & 86 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# template

![GitHub last commit (branch)](https://img.shields.io/github/last-commit/socialgouv/template/main)
![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/socialgouv/template/preproduction.yaml)
![Libraries.io dependency status for GitHub repo](https://img.shields.io/librariesio/github/socialgouv/template)
![GitHub last commit (branch)](https://img.shields.io/github/last-commit/betagouv/template/main
![Libraries.io dependency status for GitHub repo](https://img.shields.io/librariesio/github/betagouv/template)

Template minimal de la [Fabrique des ministères sociaux](https://www.fabrique.social.gouv.fr/) qui intègre nos [recommandations tech](https://socialgouv.github.io/support/docs/standards/developpement). Une présentation complète [est visible ici](https://docs.google.com/presentation/d/1DQMVxy87BEQ-VDF1tJ03jpPBbQnZtTfcDucfoMwVSM0/edit#slide=id.p).
Template minimal en Next.js qui intègre les recommandations tech beta.gouv.fr.

> ⚠️ Le [Système de Design de l'État](https://www.systeme-de-design.gouv.fr/) s'adresse **uniquement** aux développeurs et aux concepteurs, qu'ils soient agents publics ou prestataires pour des sites Internet de l'État (Ministères, Administrations centrales, Préfectures, Ambassades, etc.). cf [conditions d'utilisation](https://www.systeme-de-design.gouv.fr/utilisation-et-organisation/perimetre-d-application).

Expand All @@ -31,13 +30,6 @@ Template minimal de la [Fabrique des ministères sociaux](https://www.fabrique.s
- Healthz
- Page 404

#### En plus dans la branche `hasura` :

- Page d'authentification
- Page d'inscription
- Page profil
- Interactions avec la base de données

### D'un point de vue technique

- [storybook](https://storybook.js.org/) permettant de réaliser des stories pour les composants
Expand All @@ -53,20 +45,12 @@ Template minimal de la [Fabrique des ministères sociaux](https://www.fabrique.s
- intégration de [sentry](https://sentry.io/) pour gérer les erreurs
- intégration de [matomo](https://matomo.org/) pour les statistiques d'utilisation

#### En plus dans la branche `hasura` :

- [keycloak](https://www.keycloak.org/) qui est un serveur d'authentification (exclusive à `main`)
- [next-auth](https://next-auth.js.org/) qui est un wrapper pour gérer l'authentification au sein de l'application (exclusive à `main`)
- [hasura](https://hasura.io) qui permet d'exposer une API GraphQL sur votre Postgres et de gérer les authorisations (RBAC)

## Lancer le code

Après avoir cloné le projet :

### Développement

:warning: Avant de lancer le projet, vous devez installer `gomplate`

```bash
yarn # to install dependencies
yarn dev # to run in dev mode
Expand All @@ -82,72 +66,6 @@ Le fichier `.env.development` est utilisé pour l'environnement de développemen

:warning: Les variables d'environnement sont publiques (utilisées durant le build), ne commitez donc pas de variables privées dans ces fichiers.

#### Variables d'env

cf .env.development

en production, les secrets sont chiffrés dans GIT avec sealed-secrets.

### Branche `Hasura`

Cette branche propose des composants backends de référence.

---

```mermaid
graph LR
Browser{Browser}-->|JWT|Frontend[Frontend/API Next.js]
Browser-->KeyCloak
Frontend-->|JWT|Hasura
KeyCloak-->PG1[PostgreSQL]
KeyCloak-->|JWT|Browser
Hasura-->|RBAC|PG2[PostgreSQL]
KeyCloak-->FranceConnect
```

---

Lancer les serveurs Postgres, hasura et keycloak avec `docker-compose up`.

##### Hasura

Lancer les seeds :

```sh
yarn hasura seed apply --file books.sql --project ./hasura --database-name default --endpoint http://127.0.0.1:8082 --admin-secret myadminsecretkey
```

Mettre à jour les metadatas et migrations :

Lancer la console avec `yarn hasura console --project ./hasura --endpoint http://127.0.0.1:8082 --admin-secret myadminsecretkey`. Les modifs faites dans l'UI seront reportées dans les dossiers `hasura/metadata` et `hasura/migrations`

Cf [migrations documentation](https://hasura.io/docs/latest/migrations-metadata-seeds/manage-migrations/)

##### KeyCloak

Le template intègre [Next-auth](https://next-auth.js.org/) et [KeyCloak 20](https://www.keycloak.org/) qui assure tous les workflows d'authentification.

Le `realm` par défaut est dans [.kontinuous/files/realm-export.json](.kontinuous/files/realm-export.json). Pour générer realm utilisable par `docker-compose` à partir de celui-ci, utilisez `yarn keycloak`.

Le thème keycloak est basé sur le design-système de l'état, cf [keycloak de sill-web](https://github.com/codegouvfr/sill-web/tree/main/src/keycloak-theme).

##### FranceConnect

Cf https://partenaires.franceconnect.gouv.fr/fcp/fournisseur-service

Dans les URLs de callback définies [sur le compte FranceConnect](), utiliser `https://[votre-hostname]/realms/app-realm/broker/franceconnect-particulier/endpoint` et `https://[votre-hostname]/realms/app-realm/broker/franceconnect-particulier/endpoint/logout_response`.

## Déploiement sur kubernetes

Template utilise [kontinuous](https://github.com/socialgouv/kontinuous) pour définir et déployer ses ressources kubernetes.

Lancer `npx kontinuous build --env dev -o` pour obtenir les manifests de votre environment (`dev`, `preprod` ou `prod`).

La version dev est déployée sur OVH.

## Liens

- <https://template.fabrique.social.gouv.fr/> : Version en production du projet
- <https://socialgouv.github.io/template/> : Storybook liés à la branche principale du projet
- <https://github.com/socialgouv/keycloak-dsfr> : Thème keycloak-DSFR
- <https://socialgouv.github.io/support> : Documentation technique SocialGouv
- <https://github.com/socialgouv/> : Version initiale du template
Loading
Loading