-
Notifications
You must be signed in to change notification settings - Fork 1
72 lines (62 loc) · 2.28 KB
/
docker-deploy-stage.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
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
name: Deploy Staging
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Install Node
uses: actions/setup-node@v3
with:
node-version: '16.11.1'
# Cache action set to cache npm installed modules when package-lock or OS changes, otherwise will restore the cache
- name: Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install Dependencies
run: npm install
- name: Build
run: |
npm run build
- name: Move Build to tmp
run: |
mkdir -p /tmp/workspace/build
mv -v build/* /tmp/workspace/build
- name: Temporarily save Build to artifacts
uses: actions/upload-artifact@v2
with:
name: build-client
path: /tmp/workspace
deploy-staging:
needs: build
runs-on: ubuntu-latest
environment: staging
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.STAGE_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.STAGE_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Retrieve saved Build
uses: actions/download-artifact@v2
with:
name: build-client
path: /tmp/workspace
- name: Deploy to S3
run: aws s3 sync /tmp/workspace/build/ s3://${{ secrets.STAGE_S3_URL }}
- name: Run CF invalidation
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.STAGE_CF_ID }} --paths '/*'