-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (88 loc) · 2.65 KB
/
node-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
# https://docs.github.com/en/actions/learn-github-actions/reusing-workflows
name: "ci"
on:
workflow_call:
inputs:
gitAuthorName:
type: string
required: false
default: "GitHub"
gitAuthorEmail:
type: string
required: false
# Got the email from here:
# https://github.com/actions/checkout#push-a-commit-using-the-built-in-token
default: "github-actions@github.com"
releaseEnabled:
type: boolean
required: false
default: true
cacheEnabled:
type: boolean
required: false
default: true
secrets:
GitHubToken:
required: true
NPMToken:
required: true
env:
NODE_ENV: "ci"
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: volta-cli/action@v4
- uses: pnpm/action-setup@v4.0.0
name: Install pnpm
id: pnpm-install
with:
run_install: false
- name: Get pnpm store directory
if: inputs.cacheEnabled
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
if: inputs.cacheEnabled
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- run: "pnpm install --frozen-lockfile"
- run: "pnpm run typecheck"
- run: "pnpm run lint"
- run: "pnpm run test:coverage"
- run: "pnpm run build"
release:
if: inputs.releaseEnabled && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs:
- "test"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- uses: volta-cli/action@v4
- uses: pnpm/action-setup@v4.0.0
name: Install pnpm
id: pnpm-install
with:
run_install: false
- run: "pnpm install --frozen-lockfile --ignore-scripts"
- run: "pnpm run build"
- run: "pnpm run release"
env:
# https://github.com/semantic-release/github#github-authentication
GITHUB_TOKEN: ${{ secrets.GitHubToken }}
# https://docs.npmjs.com/creating-and-viewing-access-tokens
NPM_TOKEN: ${{ secrets.NPMToken }}
GIT_AUTHOR_NAME: ${{ inputs.gitAuthorName }}
GIT_AUTHOR_EMAIL: ${{ inputs.gitAuthorEmail }}
GIT_COMMITTER_NAME: ${{ inputs.gitAuthorName }}
GIT_COMMITTER_EMAIL: ${{ inputs.gitAuthorEmail }}