generated from homebridge/homebridge-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 3
138 lines (116 loc) · 3.13 KB
/
build.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
138
name: Test and Build
on:
push:
branches: [ latest ]
pull_request:
branches: [ latest ]
permissions:
contents: read
jobs:
build:
name: Build (Node.js v${{ matrix.node-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version:
- 18
- 20
- 21
- 22
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
fetch-tags: false
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}.x
- name: Install dependencies
run: npm install
- name: Run Build
run: npm run build
- name: Audit, fix outdated dependencies and rebuild
run: |
npm list --outdated
npm audit || true
npm audit fix || true
npm list --outdated
npm run build
test:
name: Test and report coverage
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
fetch-tags: false
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "lts/*"
- name: Install dependencies
run: npm install
- name: Run Lint
run: npm run lint
- name: Run Test
run: npm run test
- name: Codacy coverage report
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: ./coverage/lcov.info
trigger-release:
if: github.ref == 'refs/heads/latest'
name: Trigger Release on latest
runs-on: ubuntu-latest
needs: build
permissions:
contents: write
steps:
- name: Create semantic-release repository dispatch event
env:
GH_TOKEN: ${{ github.token }}
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
run: |
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{ github.repository }}/dispatches \
-f "event_type=semantic-release" \
-F "client_payload[commit_message]=$COMMIT_MESSAGE"
docs:
if: github.ref == 'refs/heads/latest'
name: Deploy docs to Pages
runs-on: ubuntu-latest
needs: build
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: false
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
fetch-tags: false
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: './docs'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4