forked from devops930-broadway/mern-ecommerce
-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (56 loc) · 2.13 KB
/
deploy-frontend-s3.yaml
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: Build and Deploy Frontend
on:
push:
branches:
- 'devlopment1'
jobs:
build-and-deploy:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
id-token: write
steps:
- name: Checkout the code
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
- name: Cache node modules
uses: actions/cache@v3
with:
path: ${{ format('{0}/{1}', env.working_dir, 'node_modules') }}
key: build-${{ hashFiles('package-lock.json') }}
restore-keys: |
build-
- name: install dependencies
run: npm install --prefer-offline --no-fund
- name: configureawscredentials
uses: aws-actions/configure-aws-credentials@v3
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
# - name: Get .env
# run: aws ssm get-parameter --name "/$GITHUB_REPOSITORY/$GITHUB_REF_NAME/env" --with-decryption --query 'Parameter.Value' --output text | tr -d '"' >.env
- name: Echo Secrets to .env File
run: |
rm -rf .env
echo "REACT_APP_WEB3_AUTH_CLIENT_ID=${{ secrets.REACT_APP_WEB3_AUTH_CLIENT_ID }}" >> .env
echo "REACT_APP_API_BASE_URL=${{ secrets.REACT_APP_API_BASE_URL }}" >> .env
echo "REACT_APP_WEB3_AUTH_ENV=${{ secrets.REACT_APP_WEB3_AUTH_ENV }}" >> .env
echo "REACT_APP_WC_PROJECT_ID=${{ secrets.REACT_APP_WC_PROJECT_ID }}" >> .env
- name: build assets
run: CI=false npm run build
- name: 'Upload Artifact'
uses: actions/upload-artifact@v3
with:
name: built-assets
path: build
retention-days: 1
- name: Upload built assets to s3 and Cloudfront Invalidation
run: |
aws s3 sync . s3://${{ secrets.BUCKET_NAME }} --delete --only-show-errors --cache-control 'max-age=31536000' --no-progress
aws cloudfront create-invalidation --distribution-id ${{ secrets.DISTRIBUTION_ID }} --paths "/index.html"