Skip to content

Commit 97d7065

Browse files
Add Github Actions CI/CD workflow
1 parent ae9acb3 commit 97d7065

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Deploy to AWS
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch: # Allows manual trigger
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: '20'
20+
cache: 'npm'
21+
22+
- name: Install dependencies
23+
run: npm ci
24+
25+
- name: Build
26+
run: npm run build
27+
28+
- name: Configure AWS credentials
29+
uses: aws-actions/configure-aws-credentials@v4
30+
with:
31+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
32+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
33+
aws-region: us-east-1
34+
35+
- name: Deploy to S3
36+
run: |
37+
aws s3 sync dist/ s3://sleuthwork-app --delete \
38+
--cache-control "public, max-age=31536000" \
39+
--exclude "index.html" \
40+
--exclude "sleuth-favicon.svg"
41+
42+
aws s3 cp dist/index.html s3://sleuthwork-app/index.html \
43+
--cache-control "public, max-age=0, must-revalidate"
44+
45+
aws s3 cp dist/sleuth-favicon.svg s3://sleuthwork-app/sleuth-favicon.svg \
46+
--cache-control "public, max-age=31536000"
47+
48+
- name: Invalidate CloudFront cache
49+
run: |
50+
aws cloudfront create-invalidation \
51+
--distribution-id E39DGXXW6LUXCG \
52+
--paths "/*"
53+
54+
- name: Deployment summary
55+
run: |
56+
echo "✅ Deployment complete!"
57+
echo "🌐 Live at: https://sleuthwork.app"

0 commit comments

Comments
 (0)