@hed-hog/cli 0.0.63 → 0.0.65

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hed-hog/cli",
3
- "version": "0.0.63",
3
+ "version": "0.0.65",
4
4
  "description": "HedHog CLI tool",
5
5
  "author": "HedHog",
6
6
  "private": false,
@@ -131,7 +131,7 @@ jobs:
131
131
  # Check DATABASE_URL
132
132
  if [ -z "$DATABASE_URL" ]; then
133
133
  echo "::error::GitHub secret DATABASE_URL is not set. Configure it in Settings > Secrets and variables > Actions."
134
- echo "::error::Expected format: postgresql://postgres:<password>@postgresql-hub:5432/hub"
134
+ echo "::error::Expected format: postgresql://postgres:<password>@postgresql-<%= config.appName %>:5432/<%= config.appName %>"
135
135
  MISSING_SECRETS="$MISSING_SECRETS DATABASE_URL"
136
136
  fi
137
137
 
@@ -235,10 +235,10 @@ jobs:
235
235
  sleep 5
236
236
 
237
237
  # Get the newest pod
238
- POD_NAME=$(kubectl get pods -l app=hub-api -n ${{ env.NAMESPACE }} --sort-by=.metadata.creationTimestamp -o name | tail -n 1 | cut -d/ -f2)
238
+ POD_NAME=$(kubectl get pods -l app=<%= config.appName %>-api -n ${{ env.NAMESPACE }} --sort-by=.metadata.creationTimestamp -o name | tail -n 1 | cut -d/ -f2)
239
239
 
240
240
  if [ -z "$POD_NAME" ]; then
241
- echo "::error::No hub-api pod found in namespace ${{ env.NAMESPACE }}"
241
+ echo "::error::No <%= config.appName %>-api pod found in namespace ${{ env.NAMESPACE }}"
242
242
  exit 1
243
243
  fi
244
244
 
@@ -252,9 +252,10 @@ jobs:
252
252
 
253
253
  for ENV_VAR in "${REQUIRED_ENVS[@]}"; do
254
254
  # Check if env var is set and not empty in the container
255
- ENV_VALUE=$(kubectl exec "$POD_NAME" -n ${{ env.NAMESPACE }} -- sh -c "echo \${ENV_VAR}" 2>/dev/null || echo "")
255
+ # Use 'printenv' to safely retrieve the environment variable value
256
+ ENV_VALUE=$(kubectl exec "$POD_NAME" -n ${{ env.NAMESPACE }} -- printenv "$ENV_VAR" 2>/dev/null || echo "")
256
257
 
257
- if [ -z "$ENV_VALUE" ] || [ "$ENV_VALUE" = "\${ENV_VAR}" ]; then
258
+ if [ -z "$ENV_VALUE" ]; then
258
259
  echo "✗ FAIL: $ENV_VAR is not set or empty in the container"
259
260
  VERIFICATION_FAILED=1
260
261
  else
@@ -273,6 +274,51 @@ jobs:
273
274
  fi
274
275
 
275
276
  echo "✓ All environment variables verified successfully in the container"
277
+ - name: Cleanup old registry manifests (API)
278
+ run: |
279
+ set -eu
280
+ REGISTRY_NAME="${REGISTRY##*/}"
281
+
282
+ cleanup_repository() {
283
+ REPOSITORY="$1"
284
+
285
+ echo "Inspecting repository ${REPOSITORY} in registry ${REGISTRY_NAME}"
286
+
287
+ TAG_ROWS="$(doctl registry repository list-tags "${REPOSITORY}" --registry "${REGISTRY_NAME}" --format Tag,ManifestDigest --no-header || true)"
288
+
289
+ if [ -z "${TAG_ROWS}" ]; then
290
+ echo "No tags found for ${REPOSITORY}; skipping cleanup."
291
+ return 0
292
+ fi
293
+
294
+ CURRENT_DIGEST="$(printf '%s\n' "${TAG_ROWS}" | awk -v target="${{ github.sha }}" '$1 == target { print $2; exit }')"
295
+
296
+ if [ -z "${CURRENT_DIGEST}" ]; then
297
+ echo "::error::Unable to determine current manifest digest for ${REPOSITORY}:${{ github.sha }}"
298
+ exit 1
299
+ fi
300
+
301
+ OLD_DIGESTS="$(printf '%s\n' "${TAG_ROWS}" | awk -v keep="${CURRENT_DIGEST}" 'NF >= 2 && $2 != keep { print $2 }' | sort -u)"
302
+
303
+ if [ -z "${OLD_DIGESTS}" ]; then
304
+ echo "No old manifests to delete for ${REPOSITORY}."
305
+ return 0
306
+ fi
307
+
308
+ echo "Deleting old manifests from ${REPOSITORY}:"
309
+ printf '%s\n' "${OLD_DIGESTS}"
310
+
311
+ printf '%s\n' "${OLD_DIGESTS}" | while IFS= read -r DIGEST; do
312
+ if [ -z "${DIGEST}" ]; then
313
+ continue
314
+ fi
315
+
316
+ doctl registry repository delete-manifest "${REPOSITORY}" "${DIGEST}" --registry "${REGISTRY_NAME}" --force
317
+ done
318
+ }
319
+
320
+ cleanup_repository "<%= config.appName %>-api"
321
+ cleanup_repository "<%= config.appName %>-api-migrate"
276
322
  <% } %>
277
323
  <% if ((config.apps || []).includes('admin')) { %>
278
324
  deploy-admin:
@@ -360,4 +406,43 @@ jobs:
360
406
  kubectl logs -l app=<%= config.appName %>-admin -n ${{ env.NAMESPACE }} --tail=50 --previous 2>/dev/null || true
361
407
  exit 1
362
408
  )
409
+ - name: Cleanup old registry manifests (ADMIN)
410
+ run: |
411
+ set -eu
412
+ REGISTRY_NAME="${REGISTRY##*/}"
413
+ REPOSITORY="<%= config.appName %>-admin"
414
+
415
+ echo "Inspecting repository ${REPOSITORY} in registry ${REGISTRY_NAME}"
416
+
417
+ TAG_ROWS="$(doctl registry repository list-tags "${REPOSITORY}" --registry "${REGISTRY_NAME}" --format Tag,ManifestDigest --no-header || true)"
418
+
419
+ if [ -z "${TAG_ROWS}" ]; then
420
+ echo "No tags found for ${REPOSITORY}; skipping cleanup."
421
+ exit 0
422
+ fi
423
+
424
+ CURRENT_DIGEST="$(printf '%s\n' "${TAG_ROWS}" | awk -v target="${{ github.sha }}" '$1 == target { print $2; exit }')"
425
+
426
+ if [ -z "${CURRENT_DIGEST}" ]; then
427
+ echo "::error::Unable to determine current manifest digest for ${REPOSITORY}:${{ github.sha }}"
428
+ exit 1
429
+ fi
430
+
431
+ OLD_DIGESTS="$(printf '%s\n' "${TAG_ROWS}" | awk -v keep="${CURRENT_DIGEST}" 'NF >= 2 && $2 != keep { print $2 }' | sort -u)"
432
+
433
+ if [ -z "${OLD_DIGESTS}" ]; then
434
+ echo "No old manifests to delete for ${REPOSITORY}."
435
+ exit 0
436
+ fi
437
+
438
+ echo "Deleting old manifests from ${REPOSITORY}:"
439
+ printf '%s\n' "${OLD_DIGESTS}"
440
+
441
+ printf '%s\n' "${OLD_DIGESTS}" | while IFS= read -r DIGEST; do
442
+ if [ -z "${DIGEST}" ]; then
443
+ continue
444
+ fi
445
+
446
+ doctl registry repository delete-manifest "${REPOSITORY}" "${DIGEST}" --registry "${REGISTRY_NAME}" --force
447
+ done
363
448
  <% } %>