Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 48c3220013 | |||
| f1bd5d9e08 | |||
| 5737fb6429 | |||
| 96eee4326a |
+36
-3
@@ -4,6 +4,7 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- 'prod/*'
|
||||
|
||||
jobs:
|
||||
test:
|
||||
@@ -26,10 +27,11 @@ jobs:
|
||||
- name: Run Maven Tests
|
||||
run: mvn clean test
|
||||
|
||||
deploy:
|
||||
name: Build & Run in Docker Container
|
||||
deploy_test:
|
||||
name: Deploy to Test Environment
|
||||
needs: test
|
||||
runs-on: self-hosted
|
||||
if: github.ref == 'refs/heads/main'
|
||||
runs-on: [self-hosted, test]
|
||||
container:
|
||||
image: docker:latest
|
||||
steps:
|
||||
@@ -51,3 +53,34 @@ jobs:
|
||||
echo "POSTGRES_PASSWORD=${DB_PASSWORD:-mypassword}" >> .env
|
||||
docker compose down app || true
|
||||
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
|
||||
|
||||
+12
-6
@@ -44,13 +44,16 @@ public class PublicInscriptionController {
|
||||
}
|
||||
|
||||
@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);
|
||||
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";
|
||||
}
|
||||
// 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)) {
|
||||
redirectAttributes.addFlashAttribute("error", "Validation CAPTCHA échouée. Veuillez réessayer.");
|
||||
return "redirect:/inscription-public/demarrer";
|
||||
@@ -65,10 +68,12 @@ public class PublicInscriptionController {
|
||||
}
|
||||
|
||||
@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);
|
||||
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";
|
||||
}
|
||||
|
||||
@@ -93,7 +98,8 @@ public class PublicInscriptionController {
|
||||
|
||||
Saison activeSaison = saisonRepository.findByEstActiveTrue().orElse(null);
|
||||
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";
|
||||
}
|
||||
|
||||
|
||||
@@ -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"
|
||||
onerror="this.style.display='none'">
|
||||
<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">
|
||||
Les inscriptions ne sont pas ouvertes pour le moment, veuillez contacter un responsable du club.
|
||||
</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 -->
|
||||
<div class="cf-turnstile mb-6" data-sitekey="1x00000000000000000000AA"></div>
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
services:
|
||||
db:
|
||||
image: postgres:16
|
||||
|
||||
Reference in New Issue
Block a user