feat: persistent payload storage and automated db migrations
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 8s
Build & Deploy / 🧪 QA (push) Successful in 1m44s
Build & Deploy / 🏗️ Build (push) Successful in 5m49s
Build & Deploy / 🚀 Deploy (push) Failing after 20s
Build & Deploy / 🧪 Smoke Test (push) Has been skipped
Build & Deploy / ⚡ Lighthouse (push) Has been skipped
Build & Deploy / ♿ WCAG (push) Has been skipped
Build & Deploy / 🛡️ Quality Gates (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 4s
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 8s
Build & Deploy / 🧪 QA (push) Successful in 1m44s
Build & Deploy / 🏗️ Build (push) Successful in 5m49s
Build & Deploy / 🚀 Deploy (push) Failing after 20s
Build & Deploy / 🧪 Smoke Test (push) Has been skipped
Build & Deploy / ⚡ Lighthouse (push) Has been skipped
Build & Deploy / ♿ WCAG (push) Has been skipped
Build & Deploy / 🛡️ Quality Gates (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 4s
This commit is contained in:
@@ -5,8 +5,6 @@ node_modules
|
|||||||
.gitignore
|
.gitignore
|
||||||
.gitea
|
.gitea
|
||||||
.github
|
.github
|
||||||
public/uploads
|
|
||||||
directus/uploads
|
|
||||||
.turbo
|
.turbo
|
||||||
reference/
|
reference/
|
||||||
.next
|
.next
|
||||||
|
|||||||
@@ -357,6 +357,10 @@ jobs:
|
|||||||
ssh root@alpha.mintel.me "cd $SITE_DIR && docker compose -p '${{ needs.prepare.outputs.project_name }}' --env-file '$ENV_FILE' pull"
|
ssh root@alpha.mintel.me "cd $SITE_DIR && docker compose -p '${{ needs.prepare.outputs.project_name }}' --env-file '$ENV_FILE' pull"
|
||||||
ssh root@alpha.mintel.me "cd $SITE_DIR && docker compose -p '${{ needs.prepare.outputs.project_name }}' --env-file '$ENV_FILE' up -d --remove-orphans"
|
ssh root@alpha.mintel.me "cd $SITE_DIR && docker compose -p '${{ needs.prepare.outputs.project_name }}' --env-file '$ENV_FILE' up -d --remove-orphans"
|
||||||
|
|
||||||
|
# Initialize PayloadCMS Database
|
||||||
|
ssh root@alpha.mintel.me "cd $SITE_DIR && docker compose -p '${{ needs.prepare.outputs.project_name }}' --env-file '$ENV_FILE' exec -T klz-app pnpm run cms:migrate"
|
||||||
|
ssh root@alpha.mintel.me "cd $SITE_DIR && docker compose -p '${{ needs.prepare.outputs.project_name }}' --env-file '$ENV_FILE' exec -T klz-app pnpm run cms:seed"
|
||||||
|
|
||||||
ssh root@alpha.mintel.me "docker system prune -f --filter 'until=24h'"
|
ssh root@alpha.mintel.me "docker system prune -f --filter 'until=24h'"
|
||||||
|
|
||||||
- name: 🧹 Post-Deploy Cleanup (Runner)
|
- name: 🧹 Post-Deploy Cleanup (Runner)
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
POSTGRES_URI: postgres://${PAYLOAD_DB_USER:-payload}:${PAYLOAD_DB_PASSWORD:-120in09oenaoinsd9iaidon}@klz-db:5432/${PAYLOAD_DB_NAME:-payload}
|
POSTGRES_URI: postgres://${PAYLOAD_DB_USER:-payload}:${PAYLOAD_DB_PASSWORD:-120in09oenaoinsd9iaidon}@klz-db:5432/${PAYLOAD_DB_NAME:-payload}
|
||||||
PAYLOAD_SECRET: ${PAYLOAD_SECRET:-fallback-secret-for-production-needs-change}
|
PAYLOAD_SECRET: ${PAYLOAD_SECRET:-fallback-secret-for-production-needs-change}
|
||||||
|
volumes:
|
||||||
|
- klz_media_data:/app/public/media
|
||||||
labels:
|
labels:
|
||||||
- "traefik.enable=true"
|
- "traefik.enable=true"
|
||||||
# HTTP ⇒ HTTPS redirect
|
# HTTP ⇒ HTTPS redirect
|
||||||
@@ -89,3 +91,5 @@ networks:
|
|||||||
volumes:
|
volumes:
|
||||||
klz_db_data:
|
klz_db_data:
|
||||||
external: false
|
external: false
|
||||||
|
klz_media_data:
|
||||||
|
external: false
|
||||||
|
|||||||
13
package.json
13
package.json
@@ -116,17 +116,8 @@
|
|||||||
"cms:bootstrap": "pnpm run cms:branding:local",
|
"cms:bootstrap": "pnpm run cms:branding:local",
|
||||||
"pdf:datasheets": "tsx ./scripts/generate-pdf-datasheets.ts",
|
"pdf:datasheets": "tsx ./scripts/generate-pdf-datasheets.ts",
|
||||||
"pdf:datasheets:legacy": "tsx ./scripts/generate-pdf-datasheets-pdf-lib.ts",
|
"pdf:datasheets:legacy": "tsx ./scripts/generate-pdf-datasheets-pdf-lib.ts",
|
||||||
"cms:schema:snapshot": "./scripts/cms-snapshot.sh",
|
"cms:migrate": "payload migrate",
|
||||||
"cms:schema:apply": "./scripts/cms-apply.sh local",
|
"cms:seed": "tsx ./scripts/seed-payload.ts",
|
||||||
"cms:schema:apply:testing": "./scripts/cms-apply.sh testing",
|
|
||||||
"cms:schema:apply:staging": "./scripts/cms-apply.sh staging",
|
|
||||||
"cms:schema:apply:prod": "./scripts/cms-apply.sh production",
|
|
||||||
"cms:pull:testing": "./scripts/sync-directus.sh pull testing",
|
|
||||||
"cms:pull:staging": "./scripts/sync-directus.sh pull staging",
|
|
||||||
"cms:pull:prod": "./scripts/sync-directus.sh pull production",
|
|
||||||
"cms:push:staging:DANGER": "./scripts/sync-directus.sh push staging",
|
|
||||||
"cms:push:testing:DANGER": "./scripts/sync-directus.sh push testing",
|
|
||||||
"cms:push:prod:DANGER": "./scripts/sync-directus.sh push production",
|
|
||||||
"pagespeed:test": "tsx ./scripts/pagespeed-sitemap.ts",
|
"pagespeed:test": "tsx ./scripts/pagespeed-sitemap.ts",
|
||||||
"pagespeed:audit": "./scripts/audit-local.sh",
|
"pagespeed:audit": "./scripts/audit-local.sh",
|
||||||
"pagespeed:urls": "tsx -e \"import sitemap from './app/sitemap'; sitemap().then(urls => console.log(urls.map(u => u.url).join('\\n')))\"",
|
"pagespeed:urls": "tsx -e \"import sitemap from './app/sitemap'; sitemap().then(urls => console.log(urls.map(u => u.url).join('\\n')))\"",
|
||||||
|
|||||||
41
scripts/seed-payload.ts
Normal file
41
scripts/seed-payload.ts
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import { getPayload } from 'payload';
|
||||||
|
import configPromise from '../payload.config';
|
||||||
|
|
||||||
|
async function seed() {
|
||||||
|
console.log('🌱 Starting PayloadCMS seed process...');
|
||||||
|
|
||||||
|
try {
|
||||||
|
const payload = await getPayload({ config: configPromise });
|
||||||
|
|
||||||
|
// Check if any users exist
|
||||||
|
const { totalDocs } = await payload.find({
|
||||||
|
collection: 'users',
|
||||||
|
limit: 1,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (totalDocs === 0) {
|
||||||
|
console.log('👤 No users found. Creating default admin user...');
|
||||||
|
await payload.create({
|
||||||
|
collection: 'users',
|
||||||
|
data: {
|
||||||
|
email: 'admin@mintel.me',
|
||||||
|
password: 'klz-admin-setup',
|
||||||
|
firstName: 'KLZ',
|
||||||
|
lastName: 'Admin',
|
||||||
|
role: 'admin',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
console.log('✅ Default admin user created successfully.');
|
||||||
|
} else {
|
||||||
|
console.log(`ℹ️ Database already contains ${totalDocs} users. Skipping user creation.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('✅ PayloadCMS seed completed successfully!');
|
||||||
|
process.exit(0);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('❌ Failed to seed PayloadCMS database:', error);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
seed();
|
||||||
Reference in New Issue
Block a user