Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/email templates v2 #516

Draft
wants to merge 6 commits into
base: dev
Choose a base branch
from
Draft
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
28 changes: 23 additions & 5 deletions .gitea/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,33 @@ jobs:
email-templates:
runs-on: ubuntu-latest
name: Update templates on Mailgun
if: github.event_name == 'push' && github.ref == 'refs/heads/feature/email-templates'
if: |
github.event_name == 'push' &&
github.ref == 'refs/heads/feature/email-templates' &&
contains(github.event.head_commit.modified, 'src/emails/') ||
contains(github.event.head_commit.modified, 'src/entry-email.tsx')
continue-on-error: true
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'

- name: Run templates build
run: npm run templates
- name: Build email templates
run: npm run build
env:
CI: true

- name: Rename email templates
run: |
mkdir -p templates/dist
cp dist/public/emails/email_confirmation.html templates/dist/authorizer_email_confirmation.html
cp dist/public/emails/password_reset.html templates/dist/authorizer_password_reset.html
cp dist/public/emails/first_publication.html templates/dist/email_first_publication.html
cp dist/public/emails/new_comment.html templates/dist/new_comment_notification.html

- name: "authorizer_email_confirmation template"
if: contains(github.event.head_commit.modified, 'src/emails/EmailConfirmation.tsx')
uses: gyto/mailgun-template-action@v2
with:
html-file: "./templates/dist/authorizer_email_confirmation.html"
Expand All @@ -52,6 +67,7 @@ jobs:
mailgun-template: "authorizer_email_confirmation"

- name: "authorizer_password_reset template"
if: contains(github.event.head_commit.modified, 'src/emails/PasswordReset.tsx')
uses: gyto/mailgun-template-action@v2
with:
html-file: "./templates/dist/authorizer_password_reset.html"
Expand All @@ -60,17 +76,19 @@ jobs:
mailgun-template: "authorizer_password_reset"

- name: "email_first_publication template"
if: contains(github.event.head_commit.modified, 'src/emails/FirstPublication.tsx')
uses: gyto/mailgun-template-action@v2
with:
html-file: "./templates/dist/authorizer_first_publication.html"
html-file: "./templates/dist/email_first_publication.html"
mailgun-api-key: ${{ secrets.MAILGUN_API_KEY }}
mailgun-domain: "discours.io"
mailgun-template: "email_first_publication"

- name: "new_comment_notification template"
if: contains(github.event.head_commit.modified, 'src/emails/NewComment.tsx')
uses: gyto/mailgun-template-action@v2
with:
html-file: "./templates/dist/authorizer_new_comment.html"
html-file: "./templates/dist/new_comment_notification.html"
mailgun-api-key: ${{ secrets.MAILGUN_API_KEY }}
mailgun-domain: "discours.io"
mailgun-template: "new_comment_notification"
39 changes: 38 additions & 1 deletion .github/workflows/node-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: "CI and E2E Tests"

on:
push:
branches: [dev]
branches: [dev, feature/email-templates-v2]

jobs:
ci:
Expand All @@ -21,6 +21,43 @@ jobs:
run: npx @biomejs/biome check src/.
- name: Lint styles
run: npx stylelint **/*.{scss,css}
- name: Build email templates
id: build-templates
if: |
contains(github.event.head_commit.modified, 'src/emails/') ||
contains(github.event.head_commit.modified, 'src/entry-email.tsx')
run: |
npm run build
mkdir -p templates/dist
# Копируем файлы с правильными именами для mailgun
for src in dist/public/emails/emails/*.html; do
name=$(basename "$src" .html)
case $name in
"email_confirmation") dst="authorizer_email_confirmation";;
"password_reset") dst="authorizer_password_reset";;
"first_publication") dst="email_first_publication";;
"new_comment") dst="new_comment_notification";;
*) continue;;
esac
cp "$src" "templates/dist/${dst}.html"
done
env:
CI: true

- name: Update Mailgun Templates
needs: build-templates
if: steps.build-templates.outputs.templates_changed == 'true'
run: |
for template in authorizer_email_confirmation authorizer_password_reset email_first_publication new_comment_notification; do
if [[ -f "templates/dist/${template}.html" ]]; then
echo "Updating $template in Mailgun..."
curl -s --user "api:${{ secrets.MAILGUN_API_KEY }}" \
https://api.mailgun.net/v3/discours.io/templates \
-F template="@templates/dist/${template}.html" \
-F name="$template"
fi
done

- name: Test production build
run: npm run build

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ edge.*
.vscode/settings.json
storybook-static
app.config.*.js
*.log
59 changes: 59 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Changelog

## [0.9.12] - 2024-12-09
- обновлена система email шаблонов:
- перенос на Solid Start с сохранением точной HTML структуры
- поддержка всех email-специфичных HTML атрибутов
- улучшена типизация компонентов
- добавлена поддержка SSR для email шаблонов
- оптимизирована структура шаблонов
- рефакторинг:
- удален устаревший compile.cjs
- email компоненты перенесены в отдельную директорию
- сохранена совместимость с email клиентами
- удалены лишние файлы маршрутизации для email шаблонов
- упрощена структура сборки шаблонов
- добавлена поддержка mailgun шаблонов
- обновлены имена файлов для соответствия mailgun
- исправлены импорты компонентов писем
- удалены неиспользуемые файлы маршрутизации и компонентов
- оптимизирована сборка и обновление шаблонов в CI

## [0.9.11] - 2024-12-09
- добавлены e2e тесты для проверки миграции с `createAsync`
- добавлены e2e тесты для проверки миграции с `createResource`
- `Row5` повышена стабильность
- `translation.json` обновлен
- добавлен документ `docs/structure.md`

## [0.9.10] - 2024-12-08
- добавлены e2e тесты для проверки миграции с `createAsync`:
- тесты базового рендеринга страниц
- тесты навигации по топикам
- тесты поисковой функциональности
- увеличены таймауты для стабильности тестов
- добавлено ожидание сетевых запросов
- исправлены проблемы запуска production сборки:
- добавлен punycode как зависимость
- отключены deprecation warnings
- исправлена конфигурация сборки

## [0.9.9] - 2024-12-07
- миграция с `createAsync` на `createResource`:
- обновлены все компоненты с поддержкой SSR
- улучшена обработка состояний загрузки/ошибок
- оптимизирована гидрация компонентов
- добавлена типобезопасность
- улучшена производительность
- обновлена документация по асинхронным паттернам в `docs/solid-async.md`

## [0.9.8] - 2024-12-06
- документация
- переезд на `createResource` вместо `cache` в `src/graphql/api`

## [0.9.7] - 2024-11-20
- solid-start решение
...

## [0.1.0] - 2020-11-20
- Первая версия на svelte (другой репозиторий)
28 changes: 26 additions & 2 deletions app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const isVercel = Boolean(process.env.VERCEL)
const isNetlify = Boolean(process.env.NETLIFY)
const isBun = Boolean(process.env.BUN)
const isCI = Boolean(process.env.CI || process.env.GITHUB_ACTIONS)
const isEmail = Boolean(process.env.EMAIL)

const preset = isNetlify ? 'netlify' : isVercel ? 'vercel_edge' : isBun ? 'bun' : 'node'
console.info(`[app.config] solid-start preset {> ${preset} <}`)
Expand Down Expand Up @@ -42,18 +43,41 @@ function checkSSL(): { key: string; cert: string } | undefined {
return undefined
}

export default defineConfig({
export const emailConfig = defineConfig({
ssr: true,
server: {
prerender: {
routes: [
"/email_confirmation",
"/password_reset",
"/first_publication",
"/new_comment"
]
}
},
vite: {
build: {
rollupOptions: {
input: 'src/entry-email.tsx',
external: ['solid-js', '@solidjs/router']
}
}
}
})

export const appConfig = defineConfig({
nitro: {
timing: true,
compatibilityDate: '2024-11-29'
},
ssr: true,
server: {
preset,
port: 3000,
https: checkSSL(),
streaming: false
},
devOverlay: isDev,
vite: viteConfig
} as SolidStartInlineConfig)

export default isEmail ? emailConfig : appConfig
Loading