-
Notifications
You must be signed in to change notification settings - Fork 0
192 lines (161 loc) · 6.4 KB
/
pull-req.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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
################################################
# GITHUB ACTION WORKFLOW NAME
################################################
name: Pull Request Event Check
################################################
# GITHUB ACTION EVENT TRIGGER
################################################
on:
workflow_dispatch:
pull_request:
branches:
- 'trunk'
- 'release/**'
- 'stable'
types: [opened, synchronize, reopened]
################################################
# GITHUB ACTION JOBS
################################################
jobs:
pull-req-check:
name: pull-req-check
runs-on: ubuntu-latest
environment: pull-req
timeout-minutes: 15
################################################
# GITHUB ACTIONS GLOBAL ENV VARIABLES
################################################
env:
REGION : NA
ENV : NA # Valid values are dev,test,live only
STACK_NAME: pull-req # Valid values are au,us,uk,p2,lf,nu,p1-sandbox,p2-stage,p2-sandbox,shared only
ROOTSTACK: cutie-app
LOG_LEVEL: DEBUG # Valid values are DEBUG,INFO,WARN and ERROR only
SAMPLE_DEBUG_LOG_RATE: 0.01 # CAUTION with this value increase cost as well.
STATUSREPORTS3Bucket: deployment-status.practera.com
STATUS: SUBMITTED
REQUESTOR: ${{ github.event.inputs.REQUESTOR }} #TODO Submitter NAME here
REASON: ${{ github.event.inputs.REASON }} #TODO commit message here
ENDPOINT: NA
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
################################################
# 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
# ################################################
# # PERFORM LINT TEST
# ################################################
- name: Run lint test if present
run: |
npm run lint --if-present
# # ###############################################################
# # # PERFORM UNIT TEST
# # ##############################################################
# - name: Performing Unit test
# run: |
# npm run sonar-test --if-present
# # ###############################################################
# # # SONARCLOUD SCANNER
# # ##############################################################
# - name: Performing Sonarcloud Scanner
# uses: SonarSource/sonarcloud-github-action@master
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# ##########################################################
# # 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: New pull request for ${{env.ROOTSTACK}}
mention: 'here'
if_mention: failure,cancelled
job_name: pull-req-check # 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
export REASON=$(git log -2 --format=%s | sed -n 2p)
export REQUESTOR=${{ github.actor }}
aws s3 cp s3://$STATUSREPORTS3Bucket/deploy-reporting.sh deploy-reporting.sh
chmod +x deploy-reporting.sh && ./deploy-reporting.sh