@panoptic-it-solutions/coolify-setup 1.1.37 → 1.1.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/generator.js CHANGED
@@ -214,6 +214,9 @@ export async function generateFiles(options) {
214
214
  // Generate GitHub workflow
215
215
  const workflow = generateWorkflow({
216
216
  projectName,
217
+ includePostgres,
218
+ dbPath,
219
+ packageManager,
217
220
  });
218
221
  writeFile('.github/workflows/build-deploy.yml', workflow);
219
222
  // Generate staging version workflow
@@ -6,6 +6,7 @@ export function generateDockerCompose(options) {
6
6
  // App service
7
7
  services.push(` app:
8
8
  image: ${REGISTRY}/${projectName}-app:latest
9
+ pull_policy: always
9
10
  restart: unless-stopped
10
11
  expose:
11
12
  - "3000"
@@ -36,8 +36,9 @@ function generateNextjsDockerfile(options) {
36
36
  // postgres must be externalized due to pnpm's symlink structure causing resolution issues
37
37
  const migrationBundle = includePostgres ? `
38
38
 
39
- # Create migrations folder if it doesn't exist (may be gitignored)
40
- RUN mkdir -p ${dbPath}/migrations
39
+ # Verify migrations exist (fail build if missing - don't silently create empty folder)
40
+ RUN echo "Checking migrations:" && ls -la ${dbPath}/migrations/ && \\
41
+ test -f ${dbPath}/migrations/meta/_journal.json || (echo "ERROR: Migrations not found! Run 'drizzle-kit generate' and commit the files." && exit 1)
41
42
 
42
43
  # Build the migration bundle (single JS file with all deps baked in)
43
44
  # This avoids module resolution issues in the standalone container
@@ -8,6 +8,7 @@ on:
8
8
 
9
9
  permissions:
10
10
  contents: write
11
+ pull-requests: write
11
12
 
12
13
  jobs:
13
14
  version:
@@ -172,5 +173,38 @@ jobs:
172
173
  echo "**Version:** v\${{ steps.version.outputs.version }}" >> \$GITHUB_STEP_SUMMARY
173
174
  echo "**Bump Type:** \${{ steps.bump.outputs.type }}" >> \$GITHUB_STEP_SUMMARY
174
175
  echo "**Skipped:** \${{ steps.version.outputs.skip_commit }}" >> \$GITHUB_STEP_SUMMARY
176
+
177
+ - name: Create sync PR to develop
178
+ if: steps.version.outputs.skip_commit != 'true'
179
+ uses: actions/github-script@v7
180
+ with:
181
+ script: |
182
+ // Check if sync PR already exists
183
+ const { data: prs } = await github.rest.pulls.list({
184
+ owner: context.repo.owner,
185
+ repo: context.repo.repo,
186
+ head: \`\${context.repo.owner}:staging\`,
187
+ base: 'develop',
188
+ state: 'open'
189
+ });
190
+
191
+ if (prs.length > 0) {
192
+ console.log(\`Sync PR #\${prs[0].number} already exists for staging -> develop\`);
193
+ return;
194
+ }
195
+
196
+ try {
197
+ const { data: pr } = await github.rest.pulls.create({
198
+ owner: context.repo.owner,
199
+ repo: context.repo.repo,
200
+ title: \`Sync: version bump v\${{ steps.version.outputs.version }} → develop\`,
201
+ body: \`Syncs the version bump commit back to develop to prevent package.json conflicts in future merges.\\n\\n**Version:** v\${{ steps.version.outputs.version }}\\n\\nMerge this PR to keep branches in sync.\`,
202
+ head: 'staging',
203
+ base: 'develop'
204
+ });
205
+ console.log(\`Created sync PR #\${pr.number}\`);
206
+ } catch (error) {
207
+ console.log(\`Sync PR creation skipped: \${error.message}\`);
208
+ }
175
209
  `;
176
210
  }
@@ -1,4 +1,7 @@
1
1
  export interface WorkflowOptions {
2
2
  projectName: string;
3
+ includePostgres?: boolean;
4
+ dbPath?: string;
5
+ packageManager?: 'pnpm' | 'npm' | 'yarn';
3
6
  }
4
7
  export declare function generateWorkflow(options: WorkflowOptions): string;
@@ -1,6 +1,65 @@
1
1
  const REGISTRY = '10.0.0.2:5000';
2
2
  export function generateWorkflow(options) {
3
- const { projectName } = options;
3
+ const { projectName, includePostgres = false, dbPath = 'src/lib/db', packageManager = 'pnpm' } = options;
4
+ const installCmd = packageManager === 'pnpm'
5
+ ? 'pnpm install --frozen-lockfile'
6
+ : packageManager === 'yarn'
7
+ ? 'yarn install --frozen-lockfile'
8
+ : 'npm ci';
9
+ const drizzleCmd = packageManager === 'pnpm'
10
+ ? 'pnpm drizzle-kit generate'
11
+ : packageManager === 'yarn'
12
+ ? 'yarn drizzle-kit generate'
13
+ : 'npx drizzle-kit generate';
14
+ const pnpmSetup = packageManager === 'pnpm' ? `
15
+ - name: Setup pnpm
16
+ run: corepack enable && corepack prepare pnpm@latest --activate
17
+ ` : '';
18
+ const migrationCheck = includePostgres ? `
19
+ - name: Setup Node.js
20
+ uses: actions/setup-node@v4
21
+ with:
22
+ node-version: '22'
23
+ ${pnpmSetup}
24
+ - name: Install dependencies
25
+ run: ${installCmd}
26
+
27
+ - name: Check migrations are up to date
28
+ run: |
29
+ # Check if migrations folder exists and has files
30
+ if [ ! -d "${dbPath}/migrations" ] || [ -z "$(ls -A ${dbPath}/migrations 2>/dev/null)" ]; then
31
+ echo "::error::Migrations folder missing or empty!"
32
+ echo "Run locally: ${drizzleCmd}"
33
+ echo "Then commit the generated migration files."
34
+ exit 1
35
+ fi
36
+
37
+ # Run generate and check if it creates NEW migration files
38
+ # (this catches schema changes that weren't migrated)
39
+ BEFORE_COUNT=$(find ${dbPath}/migrations -name "*.sql" 2>/dev/null | wc -l)
40
+ ${drizzleCmd}
41
+ AFTER_COUNT=$(find ${dbPath}/migrations -name "*.sql" 2>/dev/null | wc -l)
42
+
43
+ if [ "$AFTER_COUNT" -gt "$BEFORE_COUNT" ]; then
44
+ echo "::error::Schema changes detected without migrations!"
45
+ echo "drizzle-kit generate created new migration files."
46
+ echo ""
47
+ echo "To fix this, run locally:"
48
+ echo " ${drizzleCmd}"
49
+ echo ""
50
+ echo "Then commit the generated migration files."
51
+ git status ${dbPath}/migrations
52
+ exit 1
53
+ fi
54
+
55
+ echo "Migrations are up to date"
56
+
57
+ - name: Verify migrations exist
58
+ run: |
59
+ echo "Checking migrations in build context:"
60
+ ls -la ${dbPath}/migrations/
61
+ test -f ${dbPath}/migrations/meta/_journal.json || (echo "ERROR: _journal.json missing!" && exit 1)
62
+ ` : '';
4
63
  return `name: Build and Deploy
5
64
 
6
65
  on:
@@ -26,7 +85,7 @@ jobs:
26
85
  steps:
27
86
  - name: Checkout
28
87
  uses: actions/checkout@v4
29
-
88
+ ${migrationCheck}
30
89
  - name: Get commit SHA
31
90
  id: sha
32
91
  run: echo "sha=\$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
@@ -36,7 +95,7 @@ jobs:
36
95
  export COMMIT_SHA=\${{ steps.sha.outputs.sha }}
37
96
  export COMPOSE_PROJECT_NAME=\${{ env.PROJECT_NAME }}
38
97
 
39
- docker compose -f docker-compose.build.yml build
98
+ docker compose -f docker-compose.build.yml build --no-cache
40
99
  docker compose -f docker-compose.build.yml push
41
100
 
42
101
  # Also tag and push as latest
@@ -49,14 +108,14 @@ jobs:
49
108
  SOURCE_BRANCH="\${{ github.ref_name }}"
50
109
 
51
110
  # Feature/fix/hotfix branches target develop
52
- if [[ "\\$SOURCE_BRANCH" == feature/* ]] || [[ "\\$SOURCE_BRANCH" == fix/* ]] || [[ "\\$SOURCE_BRANCH" == hotfix/* ]]; then
53
- echo "branch=develop" >> \\$GITHUB_OUTPUT
111
+ if [[ "$SOURCE_BRANCH" == feature/* ]] || [[ "$SOURCE_BRANCH" == fix/* ]] || [[ "$SOURCE_BRANCH" == hotfix/* ]]; then
112
+ echo "branch=develop" >> $GITHUB_OUTPUT
54
113
  # Develop targets staging
55
- elif [[ "\\$SOURCE_BRANCH" == "develop" ]]; then
56
- echo "branch=staging" >> \\$GITHUB_OUTPUT
114
+ elif [[ "$SOURCE_BRANCH" == "develop" ]]; then
115
+ echo "branch=staging" >> $GITHUB_OUTPUT
57
116
  # Staging/other branches don't create PRs (staging->main handled separately)
58
117
  else
59
- echo "branch=" >> \\$GITHUB_OUTPUT
118
+ echo "branch=" >> $GITHUB_OUTPUT
60
119
  fi
61
120
 
62
121
  - name: Create deploy PR
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panoptic-it-solutions/coolify-setup",
3
- "version": "1.1.37",
3
+ "version": "1.1.39",
4
4
  "description": "CLI tool for setting up Coolify deployment on Panoptic projects",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",