-
Notifications
You must be signed in to change notification settings - Fork 0
37 lines (31 loc) · 1.37 KB
/
container.yml
File metadata and controls
37 lines (31 loc) · 1.37 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
name: CI/CD for container
on:
push:
branches:
- main
paths:
- 'packages/container/**' #only run this work flow if we make changes inside of this container
defaults:
run:
working-directory: packages/container
jobs:
build:
runs-on: ubuntu-latest # running on sopecific virtual machine
steps:
- uses: actions/checkout@v2 # checkout and use our code. similar to "use database" before quering it
- run: npm install
- run: npm run build #build our dist directory
env:
PRODUCTION_DOMAIN: ${{secrets.PRODUCTION_DOMAIN}} # exposing environment variable
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-1
- run: aws s3 sync dist s3://${{ secrets.AWS_S3_BUCKET_NAME }}/container/latest
#below is automatic invalidation so s3 serves us latest html. because s3 cache we have to invalidate the cache
- run: aws cloudfront create-invalidation --distribution-id ${{secrets.AWS_DISTRIBUTION_ID}} --path "/container/latest/index.html"
env:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}