Skip to content

Commit afe2eaa

Browse files
committed
Add CI/CD pipeline configuration for testing, publishing, and linting
1 parent 04f8e60 commit afe2eaa

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

.github/workflows/ci-cd.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: CI/CD Pipeline
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
release:
9+
types: [published]
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
node-version: [16.x, 18.x, 20.x]
17+
18+
steps:
19+
- uses: actions/checkout@v3
20+
21+
- name: Use Node.js ${{ matrix.node-version }}
22+
uses: actions/setup-node@v3
23+
with:
24+
node-version: ${{ matrix.node-version }}
25+
cache: 'npm'
26+
27+
- name: Install dependencies
28+
run: npm ci --ignore-scripts
29+
30+
- name: Run tests
31+
run: npm test
32+
33+
- name: Run examples
34+
run: |
35+
node examples/basic-usage.js
36+
node examples/advanced-usage.js
37+
node examples/user-management.js
38+
39+
publish:
40+
needs: test
41+
runs-on: ubuntu-latest
42+
if: github.event_name == 'release' && github.event.action == 'published'
43+
44+
steps:
45+
- uses: actions/checkout@v3
46+
47+
- name: Use Node.js
48+
uses: actions/setup-node@v3
49+
with:
50+
node-version: '18.x'
51+
registry-url: 'https://registry.npmjs.org'
52+
53+
- name: Install dependencies
54+
run: npm ci --ignore-scripts
55+
56+
- name: Run tests
57+
run: npm test
58+
59+
- name: Publish to npm
60+
run: npm publish
61+
env:
62+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
63+
64+
lint:
65+
runs-on: ubuntu-latest
66+
67+
steps:
68+
- uses: actions/checkout@v3
69+
70+
- name: Use Node.js
71+
uses: actions/setup-node@v3
72+
with:
73+
node-version: '18.x'
74+
75+
- name: Check package.json
76+
run: |
77+
echo "Checking package.json validity..."
78+
node -e "console.log('package.json is valid JSON')"
79+
80+
- name: Check for required files
81+
run: |
82+
echo "Checking for required files..."
83+
test -f README.md || (echo "README.md not found" && exit 1)
84+
test -f LICENSE || (echo "LICENSE not found" && exit 1)
85+
test -f package.json || (echo "package.json not found" && exit 1)
86+
test -f CHANGELOG.md || (echo "CHANGELOG.md not found" && exit 1)
87+
echo "All required files found"

0 commit comments

Comments
 (0)