Skip to content

Commit c3d9202

Browse files
committed
ci: add deploy workflow
1 parent 555c021 commit c3d9202

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Deploy tarea-03 (Vite → S3 + CloudFront)
2+
3+
on:
4+
push:
5+
branches: [ tarea-03 ]
6+
workflow_dispatch: {}
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
id-token: write
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-node@v4
18+
with:
19+
node-version: 20
20+
21+
- name: Install & Build
22+
run: |
23+
npm ci
24+
npm run build
25+
26+
- name: Configure AWS
27+
uses: aws-actions/configure-aws-credentials@v4
28+
with:
29+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
30+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
31+
aws-region: ${{ secrets.AWS_REGION }}
32+
33+
- name: Upload dist to S3
34+
run: |
35+
aws s3 sync dist/ "s3://${{ secrets.S3_BUCKET }}/" --delete \
36+
--exclude "index.html" \
37+
--cache-control "public, max-age=31536000, immutable"
38+
aws s3 cp dist/index.html "s3://${{ secrets.S3_BUCKET }}/index.html" \
39+
--cache-control "no-cache, no-store, must-revalidate"
40+
41+
- name: Invalidate CloudFront
42+
run: |
43+
aws cloudfront create-invalidation \
44+
--distribution-id "${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }}" \
45+
--paths "/*"
46+
47+
- name: Show CDN URL
48+
run: echo "CDN: https://${{ secrets.CLOUDFRONT_URL }}/"

0 commit comments

Comments
 (0)