-
Notifications
You must be signed in to change notification settings - Fork 1
79 lines (74 loc) · 2.37 KB
/
main-workflow.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
# This file contains the main workflow for the create-react-component-library project. It defines the steps and actions that are executed when a pull request is opened or pushed to the repository. The workflow includes building and testing the project, as well as deploying it to GitHub Pages if the build is successful.
# Name of the workflow
name: Testing package
# Events that trigger the workflow
on:
push:
branches: [ master ]
pull_request:
branches: ['*']
# Jobs that run as part of the workflow
jobs:
# Job to run unit tests
unit-front-end-testing:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v3
- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm test
# Job to run Components Cypress tests
cypress-components-testing:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'
registry-url: https://registry.npmjs.org/
- name: Cypress install
run: npm install
- name: Cypress run
uses: cypress-io/github-action@v5
with:
install: false
component: true
# Job to build the package
test-build-package:
if: github.ref != 'refs/heads/master'
needs: [ unit-front-end-testing, cypress-components-testing ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- run: npm ci --legacy-peer-deps
- run: npm run build
# Job to publish the package to npm
publish-npm:
if: github.ref == 'refs/heads/master'
needs: [ unit-front-end-testing, cypress-components-testing ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm publish --access=public
env:
NPM_PERSONAL_TOKEN: ${{secrets.npm_token}}