-
Notifications
You must be signed in to change notification settings - Fork 8
142 lines (120 loc) · 4.42 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
quality:
name: Quality
if: "!contains(github.event.head_commit.message, 'chore(release):')"
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x, 16.x, 17.x]
env:
CPV_CONFLUENCE_API_TOKEN: ${{ secrets.CPV_CONFLUENCE_API_TOKEN }}
CPV_CONFLUENCE_API_USERNAME: ${{ secrets.CPV_CONFLUENCE_API_USERNAME }}
CPV_CONFLUENCE_BASE_URL: ${{ secrets.CPV_CONFLUENCE_BASE_URL }}
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
CPV_JIRA_READER_API_USERNAME: ${{ secrets.CPV_JIRA_READER_API_USERNAME }}
CPV_JIRA_READER_API_TOKEN: ${{ secrets.CPV_JIRA_READER_API_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ matrix.node-version }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ matrix.node-version }}-npm-
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
- name: Tests
run: npm test
- name: Prod build
run: npm run build
- name: Install Vercel CLI
if: ${{ matrix.node-version == '16.x' }}
run: npm install --global vercel@latest
- name: Pull Vercel Environment Information
if: ${{ matrix.node-version == '16.x' }}
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Project Artifacts
if: ${{ matrix.node-version == '16.x' }}
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy Project Artifacts to Vercel
if: ${{ matrix.node-version == '16.x' }}
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
- name: Run Cypress Tests
uses: cypress-io/github-action@v2
if: ${{ steps.vercel-deploy.outputs.DEPLOYMENT_CREATED }}
with:
browser: chrome
env:
CYPRESS_BASE_URL: ${{ steps.vercel-deploy.outputs.PREVIEW_URL }}/cpv
- name: Upload Cypress Screenshots
uses: actions/upload-artifact@v3
if: failure()
with:
name: cypress-screenshots-artifacts
retention-days: 5
path: tests/e2e/cypress/screenshots/
- name: Upload Cypress Videos
uses: actions/upload-artifact@v3
if: always()
with:
name: cypress-videos-artifacts
retention-days: 1
path: tests/e2e/cypress/videos/
release:
name: Release
needs: quality
# https://github.community/t/how-do-i-specify-job-dependency-running-in-another-workflow/16482
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, 'chore(release):')
runs-on: ubuntu-latest
env:
CACHE_IMAGE: sanofiiadc/konviw
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "16.x"
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm ci
- name: Install semantic-release
run: npm install -g [email protected] @semantic-release/github @semantic-release/[email protected] @semantic-release/[email protected] @semantic-release/[email protected]
# - name: Log into Docker registry
# uses: azure/docker-login@v1
# with:
# username: ${{ secrets.SANOFI_DOCKER_HUB_USERNAME }}
# password: ${{ secrets.SANOFI_DOCKER_HUB_TOKEN }}
# - name: Pull Docker cache image
# run: docker pull --quiet ${CACHE_IMAGE} 2>/dev/null || true
- name: Semantic Release
env:
# MDF_BRANCH_TAG: latest
# MDF_BUILD_PARAMS: --cache-from ${{ env.CACHE_IMAGE }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release