From 7ea99caa194df65b3a4ff4a14e67f71b41332b5a Mon Sep 17 00:00:00 2001 From: Nicholas Dudfield Date: Thu, 30 Oct 2025 09:29:02 +0700 Subject: [PATCH] fix(cache): trim whitespace in delta count + use s3api for tagging Two fixes: 1. Restore: Trim whitespace from DELTA_COUNT to fix integer comparison 2. Save: Use 's3api put-object' instead of 's3 cp' to support --tagging The aws s3 cp command doesn't support --tagging parameter. Switched to s3api put-object which supports tagging directly. Tags are needed for lifecycle policies (30-day eviction). --- .../xahau-actions-cache-restore/action.yml | 1 + .../xahau-actions-cache-save/action.yml | 29 ++++++++++++------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/.github/actions/xahau-actions-cache-restore/action.yml b/.github/actions/xahau-actions-cache-restore/action.yml index 37daea123..908e187c2 100644 --- a/.github/actions/xahau-actions-cache-restore/action.yml +++ b/.github/actions/xahau-actions-cache-restore/action.yml @@ -107,6 +107,7 @@ runs: # Delete all delta layers for this key echo "Deleting all delta layers matching: ${CACHE_KEY}-delta-*" DELTA_COUNT=$(aws s3 ls "s3://${S3_BUCKET}/" --region "${S3_REGION}" | grep "${CACHE_KEY}-delta-" | wc -l || echo "0") + DELTA_COUNT=$(echo "${DELTA_COUNT}" | tr -d ' \n') # Trim whitespace if [ "${DELTA_COUNT}" -gt 0 ]; then aws s3 rm "s3://${S3_BUCKET}/" --recursive \ --exclude "*" \ diff --git a/.github/actions/xahau-actions-cache-save/action.yml b/.github/actions/xahau-actions-cache-save/action.yml index 1d18b881d..35a8f09d5 100644 --- a/.github/actions/xahau-actions-cache-save/action.yml +++ b/.github/actions/xahau-actions-cache-save/action.yml @@ -134,10 +134,13 @@ runs: echo "Uploading base layer to S3..." echo " Key: ${PRIMARY_KEY}-base.tar.zst" - aws s3 cp "${BASE_TARBALL}" "${S3_BASE_KEY}" \ + aws s3api put-object \ + --bucket "${S3_BUCKET}" \ + --key "${PRIMARY_KEY}-base.tar.zst" \ + --body "${BASE_TARBALL}" \ + --tagging 'type=base' \ --region "${S3_REGION}" \ - --tagging "type=base" \ - --quiet + >/dev/null echo "✓ Uploaded: ${S3_BASE_KEY}" fi @@ -178,10 +181,13 @@ runs: echo "Uploading new base layer to S3..." echo " Key: ${PRIMARY_KEY}-base.tar.zst" - aws s3 cp "${BASE_TARBALL}" "${S3_BASE_KEY}" \ + aws s3api put-object \ + --bucket "${S3_BUCKET}" \ + --key "${PRIMARY_KEY}-base.tar.zst" \ + --body "${BASE_TARBALL}" \ + --tagging 'type=base' \ --region "${S3_REGION}" \ - --tagging "type=base" \ - --quiet + >/dev/null echo "✓ Uploaded: ${S3_BASE_KEY}" fi @@ -295,11 +301,14 @@ runs: echo "Uploading timestamped delta to S3..." echo " Key: ${PRIMARY_KEY}-delta-${TIMESTAMP}-${COMMIT_SHA}.tar.zst" - # Upload with tag (deltas cleaned up inline - keep last 10) - aws s3 cp "${DELTA_TARBALL}" "${S3_DELTA_TIMESTAMPED}" \ + # Upload with tag (deltas cleaned up inline - keep last 1) + aws s3api put-object \ + --bucket "${S3_BUCKET}" \ + --key "${PRIMARY_KEY}-delta-${TIMESTAMP}-${COMMIT_SHA}.tar.zst" \ + --body "${DELTA_TARBALL}" \ + --tagging 'type=delta-archive' \ --region "${S3_REGION}" \ - --tagging "type=delta-archive" \ - --quiet + >/dev/null echo "✓ Uploaded: ${S3_DELTA_TIMESTAMPED}"