-
Notifications
You must be signed in to change notification settings - Fork 0
156 lines (143 loc) · 4.2 KB
/
ci.yml
File metadata and controls
156 lines (143 loc) · 4.2 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
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
name: CI
on:
release:
types: [released]
push:
branches:
- main
pull_request:
schedule:
- cron: '0 0 * * *'
permissions:
contents: read
jobs:
quality_checks:
name: Quality checks
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
matrix:
node: [16, 18, 20]
steps:
- name: Checkout
uses: actions/checkout@v4.1.2
- name: Setup NodeJS ${{ matrix.node }}
uses: actions/setup-node@v4.0.2
with:
node-version: ${{ matrix.node }}
cache: 'npm'
- name: Install deps
run: npm ci
- name: Run tests
run: npm test -- --coverage
security_checks:
name: Security checks
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v4.1.2
- name: Setup NodeJS 20
uses: actions/setup-node@v4.0.2
with:
node-version: '20'
cache: 'npm'
- name: Audit dependencies
run: npm audit --audit-level=low --omit=dev
lint:
name: Lint
if: github.ref != 'refs/heads/main' # Don't run for main branch
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4.1.2
- name: Lint Code Base
uses: github/super-linter/slim@v5
env:
VALIDATE_ALL_CODEBASE: false
DEFAULT_BRANCH: main
VALIDATE_JAVASCRIPT_ES: true
VALIDATE_JSON: true
VALIDATE_YAML: true
publish:
name: Publish
needs: [quality_checks, security_checks, lint]
if: github.event_name == 'release' && github.event.action == 'released'
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v4.1.2
- name: Setup NodeJS 20
uses: actions/setup-node@v4.0.2
with:
node-version: '20'
cache: 'npm'
registry-url: https://registry.npmjs.org
scope: '@quickcase'
- name: Install deps
run: npm ci
- name: Build with Webpack
run: npm run build
- name: Publish
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
end:
name: End
needs: [quality_checks, security_checks, lint, publish]
if: always()
runs-on: ubuntu-latest
timeout-minutes: 5
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
steps:
- name: Build summary
id: summary
env:
QUALITY: ${{ needs.quality_checks.result }}
SECURITY: ${{ needs.security_checks.result }}
LINT: ${{ needs.lint.result }}
PUBLISH: ${{ needs.publish.result }}
run: |
echo "success=$(if [[ "$QUALITY$SECURITY$LINT$PUBLISH" =~ ^(success|skipped)+$ ]]; then echo "true"; else echo "false"; fi)" >> $GITHUB_OUTPUT
- name: Notify slack fail
if: steps.summary.outputs.success != 'true' && env.SLACK_BOT_TOKEN != 0
uses: slackapi/slack-github-action@v1.25.0
with:
channel-id: dev
payload: |
{
"text": "${{github.repository}}: CI failed",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"emoji": true,
"text": ":x: ${{github.repository}}: CI failed"
}
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "Repository: <${{github.server_url}}/${{github.repository}}|${{github.repository}}>"
},
{
"type": "mrkdwn",
"text": "Triggered by: *${{github.triggering_actor}}*"
}
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "See failed run: <${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}|${{github.run_id}}>"
}
}
]
}