@hed-hog/cli 0.0.65 → 0.0.67

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.65",
3
+ "version": "0.0.67",
4
4
  "description": "HedHog CLI tool",
5
5
  "author": "HedHog",
6
6
  "private": false,
@@ -278,6 +278,7 @@ jobs:
278
278
  run: |
279
279
  set -eu
280
280
  REGISTRY_NAME="${REGISTRY##*/}"
281
+ DIGEST_REGEX='^sha256:[a-f0-9]{64}$'
281
282
 
282
283
  cleanup_repository() {
283
284
  REPOSITORY="$1"
@@ -291,14 +292,31 @@ jobs:
291
292
  return 0
292
293
  fi
293
294
 
294
- CURRENT_DIGEST="$(printf '%s\n' "${TAG_ROWS}" | awk -v target="${{ github.sha }}" '$1 == target { print $2; exit }')"
295
+ CURRENT_DIGEST="$(printf '%s\n' "${TAG_ROWS}" | awk -v target="${{ github.sha }}" -v regex="${DIGEST_REGEX}" '
296
+ $1 == target {
297
+ for (i = 1; i <= NF; i++) {
298
+ if ($i ~ regex) {
299
+ print $i;
300
+ exit;
301
+ }
302
+ }
303
+ }
304
+ ')"
295
305
 
296
306
  if [ -z "${CURRENT_DIGEST}" ]; then
297
307
  echo "::error::Unable to determine current manifest digest for ${REPOSITORY}:${{ github.sha }}"
298
308
  exit 1
299
309
  fi
300
310
 
301
- OLD_DIGESTS="$(printf '%s\n' "${TAG_ROWS}" | awk -v keep="${CURRENT_DIGEST}" 'NF >= 2 && $2 != keep { print $2 }' | sort -u)"
311
+ OLD_DIGESTS="$(printf '%s\n' "${TAG_ROWS}" | awk -v keep="${CURRENT_DIGEST}" -v regex="${DIGEST_REGEX}" '
312
+ {
313
+ for (i = 1; i <= NF; i++) {
314
+ if ($i ~ regex && $i != keep) {
315
+ print $i;
316
+ }
317
+ }
318
+ }
319
+ ' | sort -u)"
302
320
 
303
321
  if [ -z "${OLD_DIGESTS}" ]; then
304
322
  echo "No old manifests to delete for ${REPOSITORY}."
@@ -312,6 +330,11 @@ jobs:
312
330
  if [ -z "${DIGEST}" ]; then
313
331
  continue
314
332
  fi
333
+
334
+ if ! printf '%s\n' "${DIGEST}" | grep -Eq "${DIGEST_REGEX}"; then
335
+ echo "Skipping invalid digest candidate: ${DIGEST}"
336
+ continue
337
+ fi
315
338
 
316
339
  doctl registry repository delete-manifest "${REPOSITORY}" "${DIGEST}" --registry "${REGISTRY_NAME}" --force
317
340
  done
@@ -359,11 +382,54 @@ jobs:
359
382
  docker pull hello-world
360
383
  docker tag hello-world ${{ env.REGISTRY }}/ci-auth-probe-admin:${{ github.run_id }}
361
384
  docker push ${{ env.REGISTRY }}/ci-auth-probe-admin:${{ github.run_id }}
385
+ - name: Validate admin API URLs
386
+ run: |
387
+ set -eu
388
+
389
+ if [ -z "${{ env.ADMIN_API_URL }}" ]; then
390
+ echo "::error::ADMIN_API_URL is empty. Set it in workflow env before building admin image."
391
+ exit 1
392
+ fi
393
+
394
+ if [ -z "${{ env.ADMIN_API_BASE_URL }}" ]; then
395
+ echo "::error::ADMIN_API_BASE_URL is empty. Set it in workflow env before building admin image."
396
+ exit 1
397
+ fi
398
+
399
+ if [ -z "${{ env.ADMIN_INTERNAL_API_URL }}" ]; then
400
+ echo "::error::ADMIN_INTERNAL_API_URL is empty. Set it in workflow env before building admin image."
401
+ exit 1
402
+ fi
403
+
404
+ case "${{ env.ADMIN_API_URL }}" in
405
+ http://*|https://*) ;;
406
+ *)
407
+ echo "::error::ADMIN_API_URL must be an absolute URL (http/https). Current value: ${{ env.ADMIN_API_URL }}"
408
+ exit 1
409
+ ;;
410
+ esac
411
+
412
+ case "${{ env.ADMIN_API_BASE_URL }}" in
413
+ http://*|https://*) ;;
414
+ *)
415
+ echo "::error::ADMIN_API_BASE_URL must be an absolute URL (http/https). Current value: ${{ env.ADMIN_API_BASE_URL }}"
416
+ exit 1
417
+ ;;
418
+ esac
419
+
420
+ case "${{ env.ADMIN_INTERNAL_API_URL }}" in
421
+ http://*|https://*) ;;
422
+ *)
423
+ echo "::error::ADMIN_INTERNAL_API_URL must be an absolute URL (http/https). Current value: ${{ env.ADMIN_INTERNAL_API_URL }}"
424
+ exit 1
425
+ ;;
426
+ esac
362
427
  - name: Build Docker image
363
428
  run: |
364
- docker build -t ${{ env.REGISTRY }}/<%= config.appName %:${{ github.sha }} \
429
+ docker build -t ${{ env.REGISTRY }}/hub-admin:${{ github.sha }} \
365
430
  --build-arg NEXT_PUBLIC_API_BASE_URL=${{ env.ADMIN_API_BASE_URL }} \
366
431
  --build-arg NEXT_PUBLIC_API_URL=${{ env.ADMIN_API_URL }} \
432
+ --build-arg INTERNAL_API_URL=${{ env.ADMIN_INTERNAL_API_URL }} \
367
433
  -f apps/admin/Dockerfile .
368
434
  - name: Push Docker image (sha)
369
435
  run: |
@@ -411,6 +477,7 @@ jobs:
411
477
  set -eu
412
478
  REGISTRY_NAME="${REGISTRY##*/}"
413
479
  REPOSITORY="<%= config.appName %>-admin"
480
+ DIGEST_REGEX='^sha256:[a-f0-9]{64}$'
414
481
 
415
482
  echo "Inspecting repository ${REPOSITORY} in registry ${REGISTRY_NAME}"
416
483
 
@@ -421,14 +488,31 @@ jobs:
421
488
  exit 0
422
489
  fi
423
490
 
424
- CURRENT_DIGEST="$(printf '%s\n' "${TAG_ROWS}" | awk -v target="${{ github.sha }}" '$1 == target { print $2; exit }')"
491
+ CURRENT_DIGEST="$(printf '%s\n' "${TAG_ROWS}" | awk -v target="${{ github.sha }}" -v regex="${DIGEST_REGEX}" '
492
+ $1 == target {
493
+ for (i = 1; i <= NF; i++) {
494
+ if ($i ~ regex) {
495
+ print $i;
496
+ exit;
497
+ }
498
+ }
499
+ }
500
+ ')"
425
501
 
426
502
  if [ -z "${CURRENT_DIGEST}" ]; then
427
503
  echo "::error::Unable to determine current manifest digest for ${REPOSITORY}:${{ github.sha }}"
428
504
  exit 1
429
505
  fi
430
506
 
431
- OLD_DIGESTS="$(printf '%s\n' "${TAG_ROWS}" | awk -v keep="${CURRENT_DIGEST}" 'NF >= 2 && $2 != keep { print $2 }' | sort -u)"
507
+ OLD_DIGESTS="$(printf '%s\n' "${TAG_ROWS}" | awk -v keep="${CURRENT_DIGEST}" -v regex="${DIGEST_REGEX}" '
508
+ {
509
+ for (i = 1; i <= NF; i++) {
510
+ if ($i ~ regex && $i != keep) {
511
+ print $i;
512
+ }
513
+ }
514
+ }
515
+ ' | sort -u)"
432
516
 
433
517
  if [ -z "${OLD_DIGESTS}" ]; then
434
518
  echo "No old manifests to delete for ${REPOSITORY}."
@@ -442,6 +526,11 @@ jobs:
442
526
  if [ -z "${DIGEST}" ]; then
443
527
  continue
444
528
  fi
529
+
530
+ if ! printf '%s\n' "${DIGEST}" | grep -Eq "${DIGEST_REGEX}"; then
531
+ echo "Skipping invalid digest candidate: ${DIGEST}"
532
+ continue
533
+ fi
445
534
 
446
535
  doctl registry repository delete-manifest "${REPOSITORY}" "${DIGEST}" --registry "${REGISTRY_NAME}" --force
447
536
  done