Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 48c3220013 | |||
| f1bd5d9e08 | |||
| 5737fb6429 | |||
| 96eee4326a |
+36
-3
@@ -4,6 +4,7 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
- 'prod/*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
@@ -26,10 +27,11 @@ jobs:
|
|||||||
- name: Run Maven Tests
|
- name: Run Maven Tests
|
||||||
run: mvn clean test
|
run: mvn clean test
|
||||||
|
|
||||||
deploy:
|
deploy_test:
|
||||||
name: Build & Run in Docker Container
|
name: Deploy to Test Environment
|
||||||
needs: test
|
needs: test
|
||||||
runs-on: self-hosted
|
if: github.ref == 'refs/heads/main'
|
||||||
|
runs-on: [self-hosted, test]
|
||||||
container:
|
container:
|
||||||
image: docker:latest
|
image: docker:latest
|
||||||
steps:
|
steps:
|
||||||
@@ -51,3 +53,34 @@ jobs:
|
|||||||
echo "POSTGRES_PASSWORD=${DB_PASSWORD:-mypassword}" >> .env
|
echo "POSTGRES_PASSWORD=${DB_PASSWORD:-mypassword}" >> .env
|
||||||
docker compose down app || true
|
docker compose down app || true
|
||||||
docker compose up -d --build app
|
docker compose up -d --build app
|
||||||
|
|
||||||
|
deploy_prod:
|
||||||
|
name: Deploy to Prod Environment
|
||||||
|
needs: test
|
||||||
|
if: startsWith(github.ref, 'refs/heads/prod/')
|
||||||
|
runs-on: [self-hosted, prod]
|
||||||
|
container:
|
||||||
|
image: docker:latest
|
||||||
|
steps:
|
||||||
|
- name: Clone repository
|
||||||
|
run: |
|
||||||
|
apk add --no-cache git
|
||||||
|
SERVER_URL="${{ github.server_url }}"
|
||||||
|
SERVER_NO_PROTO="${SERVER_URL#http://}"
|
||||||
|
SERVER_NO_PROTO="${SERVER_NO_PROTO#https://}"
|
||||||
|
git clone --depth 1 "https://oauth2:${{ secrets.GITHUB_TOKEN }}@${SERVER_NO_PROTO}/${{ github.repository }}.git" .
|
||||||
|
git checkout ${{ github.sha }}
|
||||||
|
|
||||||
|
- name: Deploy with Docker Compose
|
||||||
|
env:
|
||||||
|
PROD_DB_USER: ${{ secrets.PROD_DB_USER }}
|
||||||
|
PROD_DB_PASSWORD: ${{ secrets.PROD_DB_PASSWORD }}
|
||||||
|
CAPTCHA_SECRET: ${{ secrets.CAPTCHA_SECRET }}
|
||||||
|
CAPTCHA_SITEKEY: ${{ secrets.CAPTCHA_SITEKEY }}
|
||||||
|
run: |
|
||||||
|
echo "POSTGRES_USER=${PROD_DB_USER:-myuser}" > .env
|
||||||
|
echo "POSTGRES_PASSWORD=${PROD_DB_PASSWORD:-mypassword}" >> .env
|
||||||
|
echo "CAPTCHA_SECRET=${CAPTCHA_SECRET:-1x0000000000000000000000000000000AA}" >> .env
|
||||||
|
echo "CAPTCHA_SITEKEY=${CAPTCHA_SITEKEY:-1x00000000000000000000AA}" >> .env
|
||||||
|
docker compose down app || true
|
||||||
|
docker compose up -d --build app
|
||||||
|
|||||||
+19
-13
@@ -24,10 +24,10 @@ public class PublicInscriptionController {
|
|||||||
private final PreInscriptionRepository preInscriptionRepository;
|
private final PreInscriptionRepository preInscriptionRepository;
|
||||||
private final SaisonRepository saisonRepository;
|
private final SaisonRepository saisonRepository;
|
||||||
|
|
||||||
public PublicInscriptionController(CaptchaValidationService captchaValidationService,
|
public PublicInscriptionController(CaptchaValidationService captchaValidationService,
|
||||||
TokenPreInscriptionRepository tokenRepository,
|
TokenPreInscriptionRepository tokenRepository,
|
||||||
PreInscriptionRepository preInscriptionRepository,
|
PreInscriptionRepository preInscriptionRepository,
|
||||||
SaisonRepository saisonRepository) {
|
SaisonRepository saisonRepository) {
|
||||||
this.captchaValidationService = captchaValidationService;
|
this.captchaValidationService = captchaValidationService;
|
||||||
this.tokenRepository = tokenRepository;
|
this.tokenRepository = tokenRepository;
|
||||||
this.preInscriptionRepository = preInscriptionRepository;
|
this.preInscriptionRepository = preInscriptionRepository;
|
||||||
@@ -44,13 +44,16 @@ public class PublicInscriptionController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/demarrer")
|
@PostMapping("/demarrer")
|
||||||
public String processDemarrer(@RequestParam("cf-turnstile-response") String captchaResponse, RedirectAttributes redirectAttributes) {
|
public String processDemarrer(@RequestParam("cf-turnstile-response") String captchaResponse,
|
||||||
|
RedirectAttributes redirectAttributes) {
|
||||||
Saison activeSaison = saisonRepository.findByEstActiveTrue().orElse(null);
|
Saison activeSaison = saisonRepository.findByEstActiveTrue().orElse(null);
|
||||||
if (activeSaison == null || !activeSaison.getInscriptionsOuvertes()) {
|
if (activeSaison == null || !activeSaison.getInscriptionsOuvertes()) {
|
||||||
redirectAttributes.addFlashAttribute("error", "Les inscriptions ne sont pas ouvertes pour le moment, veuillez contacter un responsable du club.");
|
redirectAttributes.addFlashAttribute("error",
|
||||||
|
"Les inscriptions ne sont pas ouvertes pour le moment, veuillez contacter un responsable du club.");
|
||||||
return "redirect:/inscription-public/demarrer";
|
return "redirect:/inscription-public/demarrer";
|
||||||
}
|
}
|
||||||
// En vrai, captchaResponse dépend du fournisseur. Cloudflare Turnstile = cf-turnstile-response
|
// En vrai, captchaResponse dépend du fournisseur. Cloudflare Turnstile =
|
||||||
|
// cf-turnstile-response
|
||||||
if (!captchaValidationService.validateCaptcha(captchaResponse)) {
|
if (!captchaValidationService.validateCaptcha(captchaResponse)) {
|
||||||
redirectAttributes.addFlashAttribute("error", "Validation CAPTCHA échouée. Veuillez réessayer.");
|
redirectAttributes.addFlashAttribute("error", "Validation CAPTCHA échouée. Veuillez réessayer.");
|
||||||
return "redirect:/inscription-public/demarrer";
|
return "redirect:/inscription-public/demarrer";
|
||||||
@@ -65,13 +68,15 @@ public class PublicInscriptionController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/formulaire")
|
@GetMapping("/formulaire")
|
||||||
public String showFormulaire(@RequestParam("token") String tokenUuid, Model model, RedirectAttributes redirectAttributes) {
|
public String showFormulaire(@RequestParam("token") String tokenUuid, Model model,
|
||||||
|
RedirectAttributes redirectAttributes) {
|
||||||
Saison activeSaison = saisonRepository.findByEstActiveTrue().orElse(null);
|
Saison activeSaison = saisonRepository.findByEstActiveTrue().orElse(null);
|
||||||
if (activeSaison == null || !activeSaison.getInscriptionsOuvertes()) {
|
if (activeSaison == null || !activeSaison.getInscriptionsOuvertes()) {
|
||||||
redirectAttributes.addFlashAttribute("error", "Les inscriptions ne sont pas ouvertes pour le moment, veuillez contacter un responsable du club.");
|
redirectAttributes.addFlashAttribute("error",
|
||||||
|
"Les inscriptions ne sont pas ouvertes pour le moment, veuillez contacter un responsable du club.");
|
||||||
return "redirect:/inscription-public/demarrer";
|
return "redirect:/inscription-public/demarrer";
|
||||||
}
|
}
|
||||||
|
|
||||||
TokenPreInscription token = tokenRepository.findByValeurUuid(tokenUuid).orElse(null);
|
TokenPreInscription token = tokenRepository.findByValeurUuid(tokenUuid).orElse(null);
|
||||||
if (token == null || !token.isValide()) {
|
if (token == null || !token.isValide()) {
|
||||||
return "public/lien-expire";
|
return "public/lien-expire";
|
||||||
@@ -84,8 +89,8 @@ public class PublicInscriptionController {
|
|||||||
|
|
||||||
@PostMapping("/formulaire")
|
@PostMapping("/formulaire")
|
||||||
public String processFormulaire(@RequestParam("token") String tokenUuid,
|
public String processFormulaire(@RequestParam("token") String tokenUuid,
|
||||||
@ModelAttribute("preInscription") PreInscription preInscription,
|
@ModelAttribute("preInscription") PreInscription preInscription,
|
||||||
RedirectAttributes redirectAttributes) {
|
RedirectAttributes redirectAttributes) {
|
||||||
TokenPreInscription token = tokenRepository.findByValeurUuid(tokenUuid).orElse(null);
|
TokenPreInscription token = tokenRepository.findByValeurUuid(tokenUuid).orElse(null);
|
||||||
if (token == null || !token.isValide()) {
|
if (token == null || !token.isValide()) {
|
||||||
return "public/lien-expire";
|
return "public/lien-expire";
|
||||||
@@ -93,7 +98,8 @@ public class PublicInscriptionController {
|
|||||||
|
|
||||||
Saison activeSaison = saisonRepository.findByEstActiveTrue().orElse(null);
|
Saison activeSaison = saisonRepository.findByEstActiveTrue().orElse(null);
|
||||||
if (activeSaison == null || !activeSaison.getInscriptionsOuvertes()) {
|
if (activeSaison == null || !activeSaison.getInscriptionsOuvertes()) {
|
||||||
redirectAttributes.addFlashAttribute("error", "Les inscriptions ne sont pas ouvertes pour le moment, veuillez contacter un responsable du club.");
|
redirectAttributes.addFlashAttribute("error",
|
||||||
|
"Les inscriptions ne sont pas ouvertes pour le moment, veuillez contacter un responsable du club.");
|
||||||
return "redirect:/inscription-public/demarrer";
|
return "redirect:/inscription-public/demarrer";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,15 +20,18 @@
|
|||||||
<img src="/images/logo.png" alt="AS Talange" class="h-32 w-auto mx-auto mb-6 object-contain drop-shadow-sm"
|
<img src="/images/logo.png" alt="AS Talange" class="h-32 w-auto mx-auto mb-6 object-contain drop-shadow-sm"
|
||||||
onerror="this.style.display='none'">
|
onerror="this.style.display='none'">
|
||||||
<h1 class="text-2xl font-bold text-gray-900 mb-2">Inscription au club</h1>
|
<h1 class="text-2xl font-bold text-gray-900 mb-2">Inscription au club</h1>
|
||||||
<p th:unless="${inscriptionsFermees}" class="text-gray-600 mb-8">Veuillez valider le captcha pour accéder au formulaire sécurisé.</p>
|
<p th:unless="${inscriptionsFermees}" class="text-gray-600 mb-8">Veuillez valider le captcha pour accéder au
|
||||||
|
formulaire sécurisé.</p>
|
||||||
|
|
||||||
|
<div th:if="${error != null and (inscriptionsFermees == null or !inscriptionsFermees)}"
|
||||||
|
class="bg-red-50 text-red-600 p-3 rounded-lg mb-6 text-sm" th:text="${error}"></div>
|
||||||
|
|
||||||
<div th:if="${error != null and (inscriptionsFermees == null or !inscriptionsFermees)}" class="bg-red-50 text-red-600 p-3 rounded-lg mb-6 text-sm" th:text="${error}"></div>
|
|
||||||
|
|
||||||
<div th:if="${inscriptionsFermees}" class="bg-red-50 text-red-600 p-4 rounded-lg mb-6 text-sm font-medium">
|
<div th:if="${inscriptionsFermees}" class="bg-red-50 text-red-600 p-4 rounded-lg mb-6 text-sm font-medium">
|
||||||
Les inscriptions ne sont pas ouvertes pour le moment, veuillez contacter un responsable du club.
|
Les inscriptions ne sont pas ouvertes pour le moment, veuillez contacter un responsable du club.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form th:unless="${inscriptionsFermees}" th:action="@{/inscription-public/demarrer}" method="post" class="flex flex-col items-center">
|
<form th:unless="${inscriptionsFermees}" th:action="@{/inscription-public/demarrer}" method="post"
|
||||||
|
class="flex flex-col items-center">
|
||||||
<!-- Remplacer par la vraie clé de site Cloudflare Turnstile -->
|
<!-- Remplacer par la vraie clé de site Cloudflare Turnstile -->
|
||||||
<div class="cf-turnstile mb-6" data-sitekey="1x00000000000000000000AA"></div>
|
<div class="cf-turnstile mb-6" data-sitekey="1x00000000000000000000AA"></div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
db:
|
db:
|
||||||
image: postgres:16
|
image: postgres:16
|
||||||
|
|||||||
Reference in New Issue
Block a user