-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
159 lines (146 loc) Β· 4.62 KB
/
action.yml
File metadata and controls
159 lines (146 loc) Β· 4.62 KB
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: 'CI/CD Pipeline'
description: 'Performs CI/CD tasks for Node.js projects'
inputs:
node_version:
description: 'Node.js version to use'
required: true
pnpm_version:
description: 'PNPM version to use'
required: false
default: ''
github_token:
description: 'GitHub token for repository checkout'
required: true
build:
description: 'Commands to run build'
required: false
default: |
pnpm run build
test:
description: 'Commands to run tests'
required: false
default: |
pnpm run test
autoupdate:
description: 'Checks updates (latest,minor,patch) and publish if applied'
required: false
branch:
description: 'Release branch name'
required: false
default: master
username:
description: 'Github username to commit'
required: false
email:
description: 'User email to commit'
required: false
npm_token:
description: 'Npm token to publish updates'
required: false
codecov_token:
description: 'Codecov token for uploading coverage'
required: false
publish_tags:
description: 'Publish on tag push matching pattern (e.g. "v*")'
required: false
runs:
using: 'composite'
steps:
- name: Checkout repository π₯
uses: actions/checkout@v6
with:
token: ${{ inputs.github_token }}
- name: Setup Node.js π οΈ
uses: actions/setup-node@v6
with:
node-version: ${{ inputs.node_version }}
registry-url: 'https://registry.npmjs.org/'
- name: Install pnpm π¦
uses: pnpm/action-setup@v5
with:
version: ${{ inputs.pnpm_version }}
run_install: false
- name: Environment log βΉοΈ
id: env
run: |
node --version
pnpm --version
echo "VERSION=$(jq -r .version package.json)" >> $GITHUB_OUTPUT
shell: bash
- name: Install dependencies π©
run: |
pnpm install --frozen-lockfile
shell: bash
- name: Check updates π
id: updates
if: ${{ inputs.autoupdate != null && github.ref == format('refs/heads/{0}', inputs.branch) }}
run: |
if ! [[ "${{ steps.env.outputs.VERSION }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "${{ steps.env.outputs.VERSION }} is not a release version"
exit 0
fi
echo "AUTOUPDATE=${{ inputs.autoupdate }}"
echo "VERSION=${{ steps.env.outputs.VERSION }}"
if [ -z "${{ inputs.username }}" ] || [ -z "${{ inputs.email }}" ] || [ -z "${{ inputs.npm_token }}" ]; then
echo "Ensure username, email, and npm_token are set for autoupdate."
exit 1
fi
npx npm-check-updates -u --target ${{ inputs.autoupdate }}
if git status --porcelain | grep -q "package.json"; then
echo "Updates were applied to package.json."
pnpm install --no-frozen-lockfile
echo "PUBLISH=true" >> $GITHUB_OUTPUT
else
echo "No updates were applied to package.json."
fi
shell: bash
- name: Check tag publish π·οΈ
id: tag_publish
if: ${{ inputs.publish_tags != null && startsWith(github.ref, 'refs/tags/') }}
run: |
TAG="${GITHUB_REF#refs/tags/}"
PATTERN="${{ inputs.publish_tags }}"
if [[ "$TAG" != $PATTERN ]]; then
echo "Tag $TAG does not match pattern $PATTERN"
exit 0
fi
BRANCH="${{ inputs.branch }}"
if ! git branch -r --contains HEAD | grep -q "origin/$BRANCH"; then
echo "Tag $TAG is not on $BRANCH branch, skipping publish"
exit 1
fi
echo "Tag $TAG matches pattern $PATTERN on $BRANCH"
echo "PUBLISH=true" >> $GITHUB_OUTPUT
shell: bash
- name: Run build process ποΈ
run: |
${{ inputs.build }}
shell: bash
- name: Run testing π§ͺ
if: inputs.test != ''
run: |
${{ inputs.test }}
shell: bash
- name: Upload test coverage π
if: inputs.codecov_token != ''
uses: codecov/codecov-action@v6
with:
token: ${{ inputs.codecov_token }}
- name: Commit πΎ
if: steps.updates.outputs.PUBLISH == 'true'
run: |
git config --global user.email "${{ inputs.email }}"
git config --global user.name "${{ inputs.username }}"
git add --all
git commit -am "autoupdate"
pnpm version patch
git push
git push --tags
shell: bash
- name: Publish π
if: steps.updates.outputs.PUBLISH == 'true' || steps.tag_publish.outputs.PUBLISH == 'true'
run: |
pnpm publish
shell: bash
env:
NODE_AUTH_TOKEN: ${{ inputs.npm_token }}