Skip to content

Commit c8690c5

Browse files
authored
Merge pull request #183 from D3vPals/feat/#181
refactor : 압축 파일 헤더 메타데이터 설정 스크립트 수정
2 parents de3c79c + 14c8e0f commit c8690c5

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

.github/workflows/front_ci-cd.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ jobs:
4141
- name: Verify Build Directory
4242
run: ls -la dist/
4343

44+
- name: Compress text-based files (gzip)
45+
run: |
46+
echo "Compressing text-based files..."
47+
for file in $(find dist/ -type f \( -iname "*.html" -o -iname "*.css" -o -iname "*.js" \)); do
48+
echo "Compressing $file"
49+
gzip -c "$file" > "$file.gz"
50+
done
51+
4452
- name: Configure AWS credentials
4553
uses: aws-actions/configure-aws-credentials@v4
4654
with:
@@ -52,24 +60,28 @@ jobs:
5260
env:
5361
BUCKET_NAME: ${{ secrets.AWS_S3_BUCKET_NAME }}
5462
run: |
63+
echo "Uploading compressed files with gzip header..."
5564
for file in $(find dist/ -type f -name "*.gz"); do
5665
original=$(echo "$file" | sed 's/\.gz$//')
5766
filename=$(basename "$original")
5867
echo "Uploading $file as $filename with Content-Encoding: gzip"
5968
aws s3 cp "$file" "s3://${BUCKET_NAME}/${filename}" \
6069
--content-encoding gzip \
61-
--metadata-directive REPLACE
70+
--metadata-directive REPLACE \
71+
--cache-control "max-age=31536000"
6272
done
6373
6474
- name: Upload non-compressed files to S3
6575
env:
6676
BUCKET_NAME: ${{ secrets.AWS_S3_BUCKET_NAME }}
6777
run: |
78+
echo "Uploading non-compressed files..."
6879
aws s3 sync dist/ s3://${BUCKET_NAME} --exclude "*.gz" --delete
6980
7081
- name: CloudFront Invalidation
7182
env:
7283
CLOUD_FRONT_ID: ${{ secrets.AWS_CLOUDFRONT_ID }}
7384
run: |
85+
echo "Creating CloudFront invalidation..."
7486
aws cloudfront create-invalidation \
7587
--distribution-id $CLOUD_FRONT_ID --paths /*

0 commit comments

Comments
 (0)