-
Notifications
You must be signed in to change notification settings - Fork 0
48 lines (38 loc) · 1.28 KB
/
deploy.yml
File metadata and controls
48 lines (38 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
name: Deploy to S3
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
types: [ closed ]
jobs:
deploy:
# Only run on push to main or when PR is merged
if: github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.merged == true)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
cache-dependency-path: './frontend/package-lock.json'
- name: Install dependencies
run: npm ci
working-directory: ./frontend
- name: Build project
run: npm run build
working-directory: ./frontend
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-central-1
- name: Deploy to S3
run: aws s3 sync ./frontend/dist/ s3://devopslab-cosmevalera --delete
- name: Invalidate CloudFront
run: |
aws cloudfront create-invalidation --distribution-id E2N2UT283KI5YO --paths "/*"