-
Notifications
You must be signed in to change notification settings - Fork 0
128 lines (125 loc) · 4.17 KB
/
ci.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
name: CI
on:
workflow_dispatch:
inputs:
git-ref:
description: Git Ref (Optional)
required: false
upload-artifacts:
description: Upload Artifacts (yes, no)
required: true
default: 'no'
push:
branches: [master]
defaults:
run:
shell: bash
jobs:
build-and-test:
name: Build and Test
environment: main_build_environment
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x, 16.x]
steps:
- name: Checkout (Latest)
if: github.event.inputs.git-ref == ''
uses: actions/checkout@v2.3.4
- name: Checkout (Custom Ref)
if: github.event.inputs.git-ref != ''
uses: actions/checkout@v2.3.4
with:
ref: ${{ github.event.inputs.git-ref }}
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2.4.0
with:
node-version: ${{ matrix.node-version }}
- name: Install Dependencies
run: npm ci
- name: Test
run: npm test
- name: Upload Test Artifacts - coverage/
if: github.event.inputs.upload-artifacts == 'yes'
uses: actions/upload-artifact@v2
with:
name: coverage-${{ matrix.node-version }}
path: ${{ github.workspace }}/coverage/
retention-days: 1
- name: Upload Test Coverage - Codecov
if: ${{ always() }}
uses: codecov/codecov-action@v2.0.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Build
run: npm run build
- name: Test E2E
run: npm run test:e2e:docker
- name: Upload Test E2E Artifacts - cypress/videos/
if: github.event.inputs.upload-artifacts == 'yes'
uses: actions/upload-artifact@v2
with:
name: cypress-videos-${{ matrix.node-version }}
path: ${{ github.workspace }}/cypress/videos/
retention-days: 1
- name: Upload Test E2E Artifacts - cypress/screenshots/
if: github.event.inputs.upload-artifacts == 'yes'
uses: actions/upload-artifact@v2
with:
name: cypress-screenshots-${{ matrix.node-version }}
path: ${{ github.workspace }}/cypress/screenshots/
retention-days: 1
- name: Test Visual
run: npm run test:visual:docker
- name: Compress Test Visual Artifacts
if: ${{ always() }}
run: |
find . -name '__diff_output__' | tar -cvjf tests-visual-job-artifacts.tar.bz2 --files-from -
- name: Upload Test Visual Artifacts - tests-visual-job-artifacts.tar.bz2
if: github.event.inputs.upload-artifacts == 'yes'
uses: actions/upload-artifact@v2
with:
name: tests-visual-job-artifacts-${{ matrix.node-version }}.tar.bz2
path: ${{ github.workspace }}/tests-visual-job-artifacts.tar.bz2
retention-days: 1
- name: Upload Build Artifacts - public/
uses: actions/upload-artifact@v2
with:
name: public-${{ matrix.node-version }}
path: ${{ github.workspace }}/public/
retention-days: 1
deploy:
name: Deploy
needs: build-and-test
runs-on: ubuntu-latest
steps:
- name: Checkout (Latest)
if: github.event.inputs.git-ref == ''
uses: actions/checkout@v2.3.4
- name: Checkout (Custom Ref)
if: github.event.inputs.git-ref != ''
uses: actions/checkout@v2.3.4
with:
ref: ${{ github.event.inputs.git-ref }}
- name: Setup Node.js 16.x
uses: actions/setup-node@v2.4.0
with:
node-version: 16.x
- name: Install Dependencies
run: npm ci
- name: Create Artifact Directories
run: |
mkdir -p ${{ github.workspace }}/public
- name: Download Artifacts
uses: actions/download-artifact@v2
with:
name: public-16.x
path: ${{ github.workspace }}/public
- name: Deploy PREVIEW
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
run: |
if [[ -n ${NETLIFY_SITE_ID} && -n ${NETLIFY_AUTH_TOKEN} ]] ; then
npm run deploy:preview
fi