1+ name : CI/CD Pipeline
2+
3+ on :
4+ push :
5+ branches : [ main, develop ]
6+ pull_request :
7+ branches : [ main ]
8+ release :
9+ types : [ published ]
10+
11+ jobs :
12+ test :
13+ runs-on : ubuntu-latest
14+
15+ strategy :
16+ matrix :
17+ node-version : [18.x, 20.x]
18+
19+ steps :
20+ - name : Checkout code
21+ uses : actions/checkout@v4
22+
23+ - name : Setup Node.js ${{ matrix.node-version }}
24+ uses : actions/setup-node@v4
25+ with :
26+ node-version : ${{ matrix.node-version }}
27+ cache : ' npm'
28+
29+ - name : Install dependencies
30+ run : npm ci
31+
32+ - name : Run linting
33+ run : npm run lint
34+
35+ - name : Run type checking
36+ run : npm run typecheck
37+
38+ - name : Run tests
39+ run : npm test
40+
41+ - name : Build extension
42+ run : npm run build
43+
44+ - name : Build Firefox version
45+ run : npm run build:firefox
46+
47+ - name : Create packages
48+ run : npm run package:all-formats
49+
50+ - name : Upload artifacts
51+ uses : actions/upload-artifact@v4
52+ with :
53+ name : extension-packages-${{ matrix.node-version }}
54+ path : |
55+ *.zip
56+ *.crx
57+ *.xpi
58+ retention-days : 30
59+
60+ security-scan :
61+ runs-on : ubuntu-latest
62+ steps :
63+ - name : Checkout code
64+ uses : actions/checkout@v4
65+
66+ - name : Setup Node.js
67+ uses : actions/setup-node@v4
68+ with :
69+ node-version : ' 20.x'
70+ cache : ' npm'
71+
72+ - name : Install dependencies
73+ run : npm ci
74+
75+ - name : Run security audit
76+ run : npm audit --audit-level=moderate
77+
78+ - name : Scan for vulnerabilities
79+ uses : securecodewarrior/github-action-add-sarif@v1
80+ if : always()
81+ with :
82+ sarif-file : ' security-scan-results.sarif'
83+
84+ release :
85+ needs : [test, security-scan]
86+ runs-on : ubuntu-latest
87+ if : github.event_name == 'release'
88+
89+ steps :
90+ - name : Checkout code
91+ uses : actions/checkout@v4
92+
93+ - name : Setup Node.js
94+ uses : actions/setup-node@v4
95+ with :
96+ node-version : ' 20.x'
97+ cache : ' npm'
98+
99+ - name : Install dependencies
100+ run : npm ci
101+
102+ - name : Build and package
103+ run : |
104+ npm run build
105+ npm run build:firefox
106+ npm run package:all-formats
107+
108+ - name : Upload release assets
109+ uses : softprops/action-gh-release@v1
110+ with :
111+ files : |
112+ *.zip
113+ *.crx
114+ *.xpi
115+ env :
116+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
117+
118+ deploy-stores :
119+ needs : [test, security-scan]
120+ runs-on : ubuntu-latest
121+ if : github.ref == 'refs/heads/main' && github.event_name == 'push'
122+
123+ steps :
124+ - name : Checkout code
125+ uses : actions/checkout@v4
126+
127+ - name : Setup Node.js
128+ uses : actions/setup-node@v4
129+ with :
130+ node-version : ' 20.x'
131+ cache : ' npm'
132+
133+ - name : Install dependencies
134+ run : npm ci
135+
136+ - name : Build and package
137+ run : |
138+ npm run build
139+ npm run build:firefox
140+ npm run package:all-formats
141+
142+ - name : Deploy to Chrome Web Store
143+ uses : PlasmoHQ/bpp@v2
144+ with :
145+ keys : ${{ secrets.CHROME_WEBSTORE_KEY }}
146+ zip-path : blog-link-analyzer-*.zip
147+ client-id : ${{ secrets.CHROME_CLIENT_ID }}
148+ client-secret : ${{ secrets.CHROME_CLIENT_SECRET }}
149+ refresh-token : ${{ secrets.CHROME_REFRESH_TOKEN }}
150+
151+ - name : Deploy to Firefox Add-ons
152+ uses : firefox-devops/firefox-addon-submit@v1
153+ with :
154+ api-key : ${{ secrets.FIREFOX_API_KEY }}
155+ api-secret : ${{ secrets.FIREFOX_API_SECRET }}
156+ xpi-path : blog-link-analyzer-firefox-*.xpi
0 commit comments