-
Notifications
You must be signed in to change notification settings - Fork 51
141 lines (123 loc) · 4.31 KB
/
dev.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Development Environment
on:
push:
branches:
- development
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Notify Slack
if: success()
id: slack
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
uses: voxmedia/github-action-slack-notify-build@v1
with:
channel_id: C01D16VJ84C
status: BUILD STARTED
color: warning
- name: Setup Nodejs
uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: Cache dependencies
id: node-cache
uses: actions/cache@v2
with:
path: |
**/node_modules
key: dev-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
if: steps.node-cache.outputs.cache-hit != 'true'
run: npm ci
- name: Build
run: npm run build
env:
CI: false
SKIP_PREFLIGHT_CHECK: true
REACT_APP_ENV: 'development'
- name: Save artifacts
uses: actions/upload-artifact@v2
with:
name: dev-frontend
path: build
# - name: Notify Slack success
# if: success()
# env:
# SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
# uses: voxmedia/github-action-slack-notify-build@v1
# with:
# message_id: ${{ steps.slack.outputs.message_id }}
# channel_id: C01D16VJ84C
# status: BUILD SUCCESSFUL
# color: good
# - name: Notify Slack failure
# if: failure()
# env:
# SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
# uses: voxmedia/github-action-slack-notify-build@v1
# with:
# message_id: ${{ steps.slack.outputs.message_id }}
# channel_id: C01D16VJ84C
# status: BUILD FAILED
# color: danger
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Notify Slack
if: success()
id: slack
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
uses: voxmedia/github-action-slack-notify-build@v1
with:
channel_id: C01D16VJ84C
status: DEPLOYMENT STARTED
color: warning
- name: Get artifacts
uses: actions/download-artifact@v2
with:
name: dev-frontend
- name: Configure AWS credetials
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: us-east-1
- name: Deploy static site to S3
run: ls -l && aws s3 sync . s3://dev-devappbarnbridgecom-origin --delete
- name: Invalidate CloudFront cache
run: |
#!/usr/bin/env bash
set -eou pipefail
CF_DIST_ID=$(aws cloudfront list-distributions --query "DistributionList.Items[?Aliases.Items!=null] | [?contains(Aliases.Items, 'dev.app.barnbridge.com')].Id | [0]" | tr -d \")
echo "Clearing cache for ${CF_DIST_ID}..."
CF_INVALIDATION_ID=$(aws cloudfront create-invalidation --distribution-id ${CF_DIST_ID} --paths "/*" | jq -r '.Invalidation.Id')
while [ $(aws cloudfront get-invalidation --distribution-id ${CF_DIST_ID} --id ${CF_INVALIDATION_ID} | jq -r '.Invalidation.Status') != "Completed" ]; do
echo "CF_DIST_ID=${CF_DIST_ID} CF_INVALIDATION_ID=${CF_INVALIDATION_ID}: Waiting for CloudFront cache invalidation to complete..."
sleep 5
done
# - name: Notify Slack success
# if: success()
# env:
# SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
# uses: voxmedia/github-action-slack-notify-build@v1
# with:
# message_id: ${{ steps.slack.outputs.message_id }}
# channel_id: C01D16VJ84C
# status: DEPLOYMENT SUCCESSFUL
# color: good
# - name: Notify Slack failure
# if: failure()
# env:
# SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
# uses: voxmedia/github-action-slack-notify-build@v1
# with:
# message_id: ${{ steps.slack.outputs.message_id }}
# channel_id: C01D16VJ84C
# status: DEPLOYMENT FAILED
# color: danger