Skip to content

Commit 1413758

Browse files
committed
feat: Add GitHub Actions deployment workflow and refactor contact form to use a single contact field instead of separate email and phone inputs.
1 parent 92a8b68 commit 1413758

6 files changed

Lines changed: 33 additions & 29 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Deploy to Coolify
2+
3+
on:
4+
push:
5+
branches:
6+
- main # Срабатывает при пуше в основную ветку
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Trigger Coolify Webhook
13+
run: |
14+
# Вставьте ваш Webhook URL из настроек Coolify в GitHub Secrets как COOLIFY_WEBHOOK
15+
curl -X GET "${{ secrets.COOLIFY_WEBHOOK }}"

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
```bash
8181
docker compose up --build -d
8282
```
83-
4. **Готово!** Сайт будет доступен по адресу: `http://localhost:4321`.
83+
4. **Готово!** Сайт будет доступен по адресу: `http://localhost:3000`.
8484
8585
### Полезные команды Docker
8686
@@ -101,6 +101,16 @@
101101
docker compose exec astro-app sh
102102
```
103103
104+
## 🔄 CI/CD Auto-Deployment (Coolify)
105+
106+
Проект настроен для автоматического развертывания через GitHub Actions и Coolify.
107+
108+
1. В настройках проекта в Coolify скопируйте **Deploy Webhook URL**.
109+
2. В репозитории GitHub перейдите в **Settings > Secrets and variables > Actions**.
110+
3. Создайте новый секрет `COOLIFY_WEBHOOK` и вставьте туда URL.
111+
112+
Теперь при каждом пуше в ветку `main` GitHub будет автоматически уведомлять Coolify о необходимости пересборки и деплоя.
113+
104114
## 📜 Доступные скрипты
105115
106116
Эти скрипты в основном используются внутри `Dockerfile` для процесса сборки, но могут быть полезны для локальной отладки без Docker (не рекомендуется для основной работы).

docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ services:
1919
# внутри контейнера. Это обязательно для доступа извне.
2020
environment:
2121
- HOST=0.0.0.0
22-
- PORT=4321
22+
- PORT=3000
2323

24-
# Пробрасываем порт 4321 из контейнера на порт 4321 вашего хост-компьютера.
24+
# Пробрасываем порт 3000 из контейнера на порт 3000 вашего хост-компьютера.
2525
# Формат: "ХОСТ:КОНТЕЙНЕР"
2626
ports:
27-
- "4321:4321"
27+
- "3000:3000"

src/components/sections/Contact.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const t = useTranslations(lang);
3030
<label class="form-label">{t("form_email")}</label>
3131
<input
3232
type="text"
33-
name="email"
33+
name="contact"
3434
placeholder="Email / Telegram / Phone"
3535
class="form-control"
3636
required

src/lib/schemas.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,11 @@ import { z } from 'zod';
77
*/
88
export const ContactFormSchema = z.object({
99
name: z.string().trim().min(2, { message: 'Name must be at least 2 characters' }).max(100),
10-
email: z.string().trim().email({ message: 'Invalid email address' }).optional().or(z.literal('')),
11-
phone: z.string().trim().min(5, { message: 'Phone is too short' }).max(20).optional().or(z.literal('')),
10+
contact: z.string().trim().min(3, { message: 'Contact information is required' }).max(100),
1211
message: z.string().trim().min(10, { message: 'Message must be at least 10 characters' }).max(2000),
1312
consent: z.coerce.boolean().refine((val) => val === true, {
1413
message: 'You must agree to personal data processing'
1514
}),
16-
}).superRefine((data, ctx) => {
17-
// If both email and phone are empty, add errors to both fields
18-
if (!data.email && !data.phone) {
19-
ctx.addIssue({
20-
code: z.ZodIssueCode.custom,
21-
message: 'Email or Phone is required',
22-
path: ['email']
23-
});
24-
ctx.addIssue({
25-
code: z.ZodIssueCode.custom,
26-
message: 'Email or Phone is required',
27-
path: ['phone']
28-
});
29-
}
3015
});
3116

3217
/**

src/pages/api/sendMessage.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,12 @@ export const POST: APIRoute = async ({ request }) => {
2525
}), { status: 400 });
2626
}
2727

28-
const { name, email, phone, message } = result.data;
29-
30-
// Prepare TG message
31-
const contactInfo = [
32-
email ? `<b>Email:</b> ${cleanInput(email)}` : null,
33-
phone ? `<b>Телефон:</b> ${cleanInput(phone)}` : null
34-
].filter(Boolean).join('\n');
28+
const { name, contact, message } = result.data;
3529

3630
const tgMessage = [
3731
`<b>🔥 Новая заявка с сайта!</b>`,
3832
`<b>Имя:</b> ${cleanInput(name)}`,
39-
contactInfo,
33+
`<b>Контакты:</b> ${cleanInput(contact)}`,
4034
`\n<b>Сообщение:</b>\n${cleanInput(message)}`
4135
].join('\n');
4236

0 commit comments

Comments
 (0)