-
Notifications
You must be signed in to change notification settings - Fork 0
47 lines (37 loc) · 1.2 KB
/
main.yml
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
name: Deploy to S3 and Invalidate CloudFront with Assume Role
on:
push:
branches:
- main
workflow_dispatch:
permissions:
id-token: write
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18' # Specify the Node.js version you need
- name: Install dependencies
run: npm install
- name: Build project
run: npm run build
- name: Configure AWS credentials using Assume Role
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: arn:aws:iam::195210670873:role/johnbrennan.codes-trust-role
aws-region: us-west-2
role-session-name: johnbrennan.codes-trust-role
- name: Sync S3 bucket
run: |
aws s3 sync ./dist ${{ secrets.PORTFOLIO_BUCKET }} --delete # Ensure correct path to built files
- name: Invalidate CloudFront cache
run: |
aws cloudfront create-invalidation \
--distribution-id ${{ secrets.PORTFOLIO_CLOUDFRONT_DISTRIBUTION_ID }} \
--paths "/*"