Getting Started with GitHub Actions

Offical Doc:
https://docs.github.com/en/actions

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
name: CI

on:
push:
branches: ['main']
pull_request:
branches: ['main']

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'pnpm'

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
run_install: false

- name: Install dependencies
run: pnpm install

- name: Lint
run: pnpm -r lint

- name: Run tests
run: pnpm -r test

- name: Build packages
run: pnpm -r build

storybook:
runs-on: ubuntu-latest
needs: build-and-test

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'pnpm'

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
run_install: false

- name: Install dependencies
run: pnpm install

- name: Build Storybook
run: cd apps/docs && pnpm build

- name: Deploy to GitHub Pages
if: github.ref == 'refs/heads/main'
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: apps/docs/storybook-static
branch: gh-pages

publish.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
name: Publish

on:
release:
types: [created]

jobs:
build-and-publish:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
cache: 'pnpm'

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
run_install: false

- name: Install dependencies
run: pnpm install

- name: Lint
run: pnpm -r lint

- name: Run tests
run: pnpm -r test

- name: Build packages
run: pnpm -r build

- name: Publish packages
run: pnpm -r publish --access public --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

Getting Started with GitHub Actions
https://www.hardyhu.cn/2025/03/14/Getting-Started-with-GitHub-Actions/
Author
John Doe
Posted on
March 14, 2025
Licensed under