@@ -32,47 +32,41 @@ jobs:
3232
3333 - name : Build and publish each layer from backend/layers/
3434 run : |
35+ mkdir -p layer_zips
36+
3537 for dir in backend/layers/*; do
3638 if [ -f "$dir/requirements.txt" ]; then
3739 LAYER_NAME=$(basename "$dir")
3840 echo "🔧 Building layer: $LAYER_NAME"
3941
40- # Clean old build (if any) and recreate
4142 rm -rf "$dir/python"
4243 mkdir -p "$dir/python"
4344
44- # Install dependencies
4545 pip install --upgrade --no-cache-dir -r "$dir/requirements.txt" -t "$dir/python"
4646
47- # Clean unnecessary files
4847 find "$dir/python" -type d -name "__pycache__" -exec rm -rf {} +
4948 find "$dir/python" -type d -name "tests" -exec rm -rf {} +
5049 find "$dir/python" -type f -name "*.pyc" -delete
5150 find "$dir/python" -type d -name "*.dist-info" -exec rm -rf {} +
5251
53- # Zip the layer
54- zip_path="${LAYER_NAME}.zip"
52+ ZIP_PATH="layer_zips/${LAYER_NAME}.zip"
53+
54+ echo "📦 Zipping to $ZIP_PATH"
5555 cd "$dir"
56- zip -r "../../${zip_path }" python > /dev/null
56+ zip -r "../../${ZIP_PATH }" python > /dev/null
5757 cd - > /dev/null
5858
59- # Upload to S3
60- echo "📤 Uploading $zip_path to S3"
61- aws s3 cp "$zip_path" s3://$S3_BUCKET/layers/$zip_path
59+ echo "📤 Uploading $ZIP_PATH to S3"
60+ aws s3 cp "$ZIP_PATH" s3://$S3_BUCKET/layers/${LAYER_NAME}.zip
6261
63- # Publish the Lambda layer
6462 echo "🚀 Publishing layer: $LAYER_NAME"
6563 LAYER_ARN=$(aws lambda publish-layer-version \
6664 --layer-name "$LAYER_NAME" \
6765 --description "Lambda layer for $LAYER_NAME" \
68- --content S3Bucket=$S3_BUCKET,S3Key=layers/$zip_path \
66+ --content S3Bucket=$S3_BUCKET,S3Key=layers/${LAYER_NAME}.zip \
6967 --compatible-runtimes $PYTHON_VERSION \
7068 --query 'LayerVersionArn' --output text)
7169
7270 echo "✅ Published $LAYER_NAME: $LAYER_ARN"
73-
74- # Optionally remove the zip after upload
75- rm -f "$zip_path"
7671 fi
77- done
78-
72+ done
0 commit comments