Skip to content

Commit 7117e70

Browse files
committed
Switch to github actions
1 parent 7748bf1 commit 7117e70

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed

.github/workflows/ci.yml

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: CI Pipeline
2+
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
tags:
8+
- 'v*.*.*'
9+
pull_request:
10+
branches:
11+
- '*'
12+
release:
13+
types: [created]
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Node.js 20.x
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: 20
26+
27+
- name: Cache node_modules
28+
uses: actions/cache@v4
29+
with:
30+
path: node_modules
31+
key: v1-dependencies-${{ hashFiles('package.json', 'package-lock.json') }}
32+
33+
- name: Install dependencies
34+
run: npm ci
35+
36+
- name: Run tests with coverage
37+
run: npm run test
38+
39+
- name: Lint code
40+
run: npm run lint
41+
42+
- name: Build project
43+
run: npm run build
44+
45+
release:
46+
runs-on: ubuntu-latest
47+
needs: build
48+
steps:
49+
- name: Checkout repository
50+
uses: actions/checkout@v4
51+
52+
- name: Set up Node.js 20.x
53+
uses: actions/setup-node@v4
54+
with:
55+
node-version: 20
56+
57+
- name: Cache node_modules
58+
uses: actions/cache@v4
59+
with:
60+
path: node_modules
61+
key: v1-dependencies-${{ hashFiles('package.json', 'package-lock.json') }}
62+
63+
- name: Install dependencies
64+
run: npm ci
65+
66+
- name: Install hub CLI for GitHub releases
67+
run: |
68+
wget https://github.com/github/hub/releases/download/v2.5.1/hub-linux-amd64-2.5.1.tgz
69+
tar xzvf hub-linux-amd64-2.5.1.tgz
70+
sudo ./hub-linux-amd64-2.5.1/install
71+
72+
- name: Configure git
73+
run: |
74+
git config --global user.email "no-reply@civic.com"
75+
git config --global user.name "CI Deployer"
76+
77+
- name: Create GitHub release
78+
run: npm run release:create
79+
env:
80+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GitHub automatically provides this
81+
82+
- name: Delete release tag
83+
run: |
84+
git push --delete origin ${{ github.ref_name }}
85+
86+
- name: Delete GitHub release
87+
run: hub release delete ${{ github.ref_name }}
88+
env:
89+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90+
91+
deploy:
92+
runs-on: ubuntu-latest
93+
needs: build
94+
steps:
95+
- name: Checkout repository
96+
uses: actions/checkout@v4
97+
98+
- name: Set up Node.js 20.x
99+
uses: actions/setup-node@v4
100+
with:
101+
node-version: 20
102+
103+
- name: Authenticate with npm registry
104+
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
105+
106+
- name: Publish to npm
107+
run: npm publish --access=public

0 commit comments

Comments
 (0)