-
Notifications
You must be signed in to change notification settings - Fork 1
79 lines (66 loc) · 1.98 KB
/
prod-deploy.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
68
69
70
71
72
73
74
75
76
77
78
79
name: Deploy prod
# A version is denoted with a protected tag.
on:
push:
# Only tags which match the protected tag pattern will trigger this workflow
tags:
- v*.*.*
env:
BUCKET_NAME: storybook-nolus
CLOUDFRONT_ID: E213OV9IDTDHKX
AWS_REGION: eu-west-1
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
jobs:
build:
name: Build static files
runs-on: ubuntu-latest
container: node:20.9.0
steps:
- uses: actions/checkout@v3
- name: Build
run: |
npm install
npm run build-storybook
- name: Archive src
uses: actions/upload-artifact@v3
with:
name: src
path: dist/
deploy:
name: Deploy to AWS
runs-on: ubuntu-20.04
container: amazon/aws-cli
environment: production
needs: build
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Download src
uses: actions/download-artifact@v3
with:
name: src
path: dist/
- name: Sync bucket
run: |
aws s3 sync dist/ s3://${BUCKET_NAME}
invalidate-cache:
name: Invalidate cache
runs-on: ubuntu-20.04
container: amazon/aws-cli
environment: production
needs: deploy
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Invalidate cloudfront cache
run: |
aws cloudfront create-invalidation --distribution-id ${CLOUDFRONT_ID} --paths "/*" --output table
echo "Cache invalidation usually takes a couple of minutes"