-
Notifications
You must be signed in to change notification settings - Fork 0
175 lines (146 loc) · 5.7 KB
/
build-deploy.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
################################################
# GITHUB ACTION WORKFLOW NAME
################################################
name: Practera Docs Build and Deploy
################################################
# GITHUB ACTION EVENT TRIGGER
################################################
on:
workflow_dispatch:
push:
branches:
- trunk
################################################
# GITHUB ACTION JOBS
################################################
jobs:
practera-docs:
name: practera-docs
runs-on: ubuntu-latest
################################################
# GITHUB ACTIONS GLOBAL ENV VARIABLES
################################################
env:
REGION : global
ENV : live # Valid values are dev,test,live onl
STACK_NAME: global-live # Valid values are global-stage,global-live only
ROOTSTACK: practera-docs
CFNS3BucketName: devops-cfn-templates
PRIVATES3BucketName: devops-shared-private
STATUSREPORTS3Bucket: deployment-status.practera.com
STATUS: DEPLOYED
ENDPOINT: https://intersective.github.io/docs/
BRANCH_TAG_NAME: trunk
################################################
# GITHUB REPO CHECKOUT
################################################
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
################################################
# NODE ENV
################################################
- name: Setup Node.js environment
uses: actions/setup-node@v2
with:
node-version: '14'
################################################
# NODE MODULES CACHE
################################################
- name: Cache node modules
uses: actions/cache@v2
id: cache-node-modules
env:
cache-name: cache
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: |
~/.npm
node_modules
*/*/node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
################################################
# NODE MODULES INSTALL
################################################
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm install
################################################
# BUILD PACKAGE
################################################
- name: npm build packages
run: npm run build
################################################
# AWS CLI CONFIGURATION - DEVOPS
################################################
- name: Configure AWS credentials from $STACK_NAME account in $REGION region
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.DEVOPS_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DEVOPS_AWS_SECRET_ACCESS_KEY }}
aws-region: ap-southeast-2
################################################
# DEPLOY GH PAGES
################################################
- name: Deploy gh pages
uses: JamesIves/github-pages-deploy-action@4.1.4
with:
branch: gh-pages # The branch the action should deploy to.
folder: src/.vuepress/dist # The folder the action should deploy.
# ##########################################################
# # SLACK NOTIFICATION
# ##########################################################
- name: Slack Notification
if: always() # Pick up events even if the job fails or is canceled.
uses: 8398a7/action-slack@v3
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
MATRIX_CONTEXT: ${{ toJson(matrix) }} # required
with:
status: ${{ job.status }}
author_name: practera docs deployed
mention: 'here'
if_mention: failure,cancelled
job_name: practera-docs # Match the name above.
fields: repo,commit,eventName,ref,workflow,message,author,job,took
custom_payload: |
{
username: 'GitHub Action CI WorkFlow',
icon_emoji: ':github:',
attachments: [{
color: '${{ job.status }}' === 'success' ? 'good' : ${{ job.status }}' === 'failure' ? 'danger' : 'warning',
text:
`${process.env.AS_REPO}\n
${process.env.AS_COMMIT}\n
${process.env.AS_EVENT_NAME}\n
@${process.env.AS_REF}\n
@${process.env.AS_WORKFLOW}\n
${process.env.AS_MESSAGE}\n
${process.env.AS_AUTHOR}\n
${process.env.AS_JOB}\n
${process.env.AS_TOOK}`,
}]
}
# ################################################
# # STATUS VARIABLE UPDATE
# ################################################
- name: Deployment status variable update
if: ${{ failure() }}
run: |
echo "STATUS=FAILURE" >> $GITHUB_ENV
# ################################################
# # DEVOPS-DEPLOYMENT REPORT
# ################################################
- name: DevOps Deployment Reporting
if: always()
run: |
pip install --upgrade pip
pip install --upgrade csvtotable
aws s3 cp s3://$STATUSREPORTS3Bucket/deploy-reporting.sh deploy-reporting.sh
chmod +x deploy-reporting.sh && ./deploy-reporting.sh
echo "LINK="${GITHUB_REPOSITORY##*/}.html >> $GITHUB_ENV