-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
137 lines (125 loc) Β· 3.82 KB
/
action.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
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
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
runs:
using: 'composite'
steps:
- name: Checkout repository π₯
uses: actions/checkout@v4
with:
token: ${{ inputs.github_token }}
- name: Setup Node.js π οΈ
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node_version }}
registry-url: 'https://registry.npmjs.org/'
- name: Install pnpm π¦
uses: pnpm/action-setup@v4
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]+-[A-Za-z0-9]+$ ]]; then
echo "${{ steps.env.outputs.VERSION }} is not a release"
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: 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@v4
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'
run: |
echo "//registry.npmjs.org/:_authToken=${{ inputs.npm_token }}" > .npmrc
npm publish
rm .npmrc
shell: bash