Skip to content

Commit d7a74f3

Browse files
committed
ci: setup github actions
ci: separate ci and release workflows
1 parent cd71f50 commit d7a74f3

File tree

3 files changed

+162
-2
lines changed

3 files changed

+162
-2
lines changed

.github/workflows/ci.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
test:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Git Checkout
11+
uses: actions/checkout@v2
12+
13+
- name: Setup node
14+
uses: actions/setup-node@v3
15+
with:
16+
node-version: 16
17+
18+
- name: Cache packages
19+
uses: actions/cache@v3
20+
with:
21+
key: node_modules-v4-${{ hashFiles('yarn.lock') }}
22+
path: |-
23+
node_modules
24+
*/node_modules
25+
restore-keys: 'node_modules-v4-'
26+
27+
- name: Yarn install
28+
run: yarn install --ignore-optional --frozen-lockfile
29+
30+
- name: Test
31+
run: yarn run test:ci
32+
33+
build-library:
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Git Checkout
37+
uses: actions/checkout@v2
38+
39+
- name: Setup node
40+
uses: actions/setup-node@v3
41+
with:
42+
node-version: 16
43+
44+
- name: Cache packages
45+
uses: actions/cache@v3
46+
with:
47+
key: node_modules-v4-${{ hashFiles('yarn.lock') }}
48+
path: |-
49+
node_modules
50+
*/node_modules
51+
restore-keys: 'node_modules-v4-'
52+
53+
- name: Yarn install
54+
run: yarn install --ignore-optional --frozen-lockfile
55+
56+
- name: Build library
57+
run: yarn run build
58+
59+
build-storybook:
60+
runs-on: ubuntu-latest
61+
steps:
62+
- name: Git Checkout
63+
uses: actions/checkout@v2
64+
65+
- name: Setup node
66+
uses: actions/setup-node@v3
67+
with:
68+
node-version: 16
69+
70+
- name: Cache packages
71+
uses: actions/cache@v3
72+
with:
73+
key: node_modules-v4-${{ hashFiles('yarn.lock') }}
74+
path: |-
75+
node_modules
76+
*/node_modules
77+
restore-keys: 'node_modules-v4-'
78+
79+
- name: Yarn install
80+
run: yarn install --ignore-optional --frozen-lockfile
81+
82+
- name: Build Storybook
83+
run: yarn run build:storybook

.github/workflows/release.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- next
8+
- beta
9+
- alpha
10+
- '*.x' # maintenance releases
11+
12+
jobs:
13+
release-library:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Git Checkout
17+
uses: actions/checkout@v2
18+
19+
- name: Setup node
20+
uses: actions/setup-node@v3
21+
with:
22+
node-version: 16
23+
24+
- name: Cache packages
25+
uses: actions/cache@v3
26+
with:
27+
key: node_modules-v4-${{ hashFiles('yarn.lock') }}
28+
path: |-
29+
node_modules
30+
*/node_modules
31+
restore-keys: 'node_modules-v4-'
32+
33+
- name: Yarn install
34+
run: yarn install --ignore-optional --frozen-lockfile
35+
36+
- name: Build library
37+
run: yarn run build
38+
39+
- name: Deploy library
40+
run: yarn run semantic-release || true
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
44+
45+
release-storybook:
46+
needs:
47+
- release-library
48+
if: github.ref == 'refs/heads/master'
49+
runs-on: ubuntu-latest
50+
steps:
51+
- name: Git Checkout
52+
uses: actions/checkout@v2
53+
54+
- name: Setup node
55+
uses: actions/setup-node@v3
56+
with:
57+
node-version: 16
58+
59+
- name: Cache packages
60+
uses: actions/cache@v3
61+
with:
62+
key: node_modules-v4-${{ hashFiles('yarn.lock') }}
63+
path: |-
64+
node_modules
65+
*/node_modules
66+
restore-keys: 'node_modules-v4-'
67+
68+
- name: Yarn install
69+
run: yarn install --ignore-optional --frozen-lockfile
70+
71+
- name: Build Storybook
72+
run: yarn run build:storybook
73+
74+
- name: Deploy Storybook
75+
run: ./node_modules/.bin/firebase deploy --token=$FIREBASE_TOKEN
76+
env:
77+
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@
3434
"scripts": {
3535
"start": "start-storybook -p 9009",
3636
"build:storybook": "build-storybook -o ./storybook",
37-
"build": "rm -rf dist && npm run build:prod",
37+
"build": "rm -rf dist && yarn run build:prod",
3838
"build:dev": "cross-env NODE_ENV=development rollup -c",
3939
"build:prod": "cross-env NODE_ENV=production rollup -c",
4040
"test": "jest ./src",
4141
"test:ci": "jest ./src --maxWorkers=2",
4242
"test:watch": "jest ./src --watch",
4343
"test:coverage": "jest ./src --coverage",
4444
"lint": "eslint src --ext .js",
45-
"lint:fix": "npm run lint -- --fix",
45+
"lint:fix": "yarn run lint --fix",
4646
"semantic-release": "semantic-release",
4747
"cz": "git-cz"
4848
},

0 commit comments

Comments
 (0)