@@ -3,9 +3,10 @@ name: CI
33permissions :
44 contents : read
55 security-events : write
6+ pull-requests : write
67
78on :
8- push :
9+ pull_request :
910 branches :
1011 - ' **'
1112
@@ -128,3 +129,130 @@ jobs:
128129 with :
129130 name : clamav-scan-log
130131 path : clamav-scan.log
132+
133+ build_extension :
134+ name : Build Extension
135+ runs-on : ubuntu-latest
136+ strategy :
137+ matrix :
138+ node-version : [20.x]
139+ steps :
140+ - name : Checkout repository
141+ uses : actions/checkout@v4
142+
143+ - name : Setup Node.js
144+ uses : actions/setup-node@v4
145+ with :
146+ node-version : ${{ matrix.node-version }}
147+
148+ - name : Install dependencies
149+ run : yarn install --frozen-lockfile
150+
151+ - name : Build extension zip
152+ run : yarn build-zip
153+
154+ - name : Get extension version
155+ id : version
156+ run : |
157+ VERSION=$(node -p "require('./package.json').version")
158+ echo "version=$VERSION" >> $GITHUB_OUTPUT
159+ echo "Extension version: $VERSION"
160+
161+ - name : Upload extension zip as artifact
162+ uses : actions/upload-artifact@v4
163+ with :
164+ name : tabee-extension-v${{ steps.version.outputs.version }}
165+ path : tabee.zip
166+ retention-days : 30
167+
168+ - name : Find PR number
169+ id : pr
170+ run : |
171+ PR_NUMBER="${{ github.event.pull_request.number }}"
172+ echo "number=$PR_NUMBER" >> $GITHUB_OUTPUT
173+ echo "PR Number: $PR_NUMBER"
174+
175+ - name : Comment PR with download link
176+ if : steps.pr.outputs.number != ''
177+ uses : actions/github-script@v7
178+ with :
179+ github-token : ${{ secrets.GITHUB_TOKEN }}
180+ script : |
181+ const fs = require('fs');
182+ const path = require('path');
183+
184+ // The zip file is at the root
185+ const zipFile = 'tabee.zip';
186+
187+ if (!fs.existsSync(zipFile)) {
188+ console.log('No zip file found at:', zipFile);
189+ return;
190+ }
191+
192+ const version = '${{ steps.version.outputs.version }}';
193+ const runId = context.runId;
194+ const repo = context.repo;
195+ const prNumber = ${{ steps.pr.outputs.number }};
196+
197+ // Get the artifact ID for direct download link
198+ const { data: artifacts } = await github.rest.actions.listWorkflowRunArtifacts({
199+ owner: repo.owner,
200+ repo: repo.repo,
201+ run_id: runId
202+ });
203+
204+ const artifact = artifacts.artifacts.find(a => a.name.startsWith('tabee-extension-v'));
205+ const artifactUrl = artifact
206+ ? `https://github.com/${repo.owner}/${repo.repo}/actions/runs/${runId}/artifacts/${artifact.id}`
207+ : `https://github.com/${repo.owner}/${repo.repo}/actions/runs/${runId}`;
208+
209+ const comment = `## 📦 Extension Build Ready!
210+
211+ **Version**: \`${version}\`
212+
213+ ### 📥 [Download Extension (${zipFile})](${artifactUrl})
214+
215+ ### Installation
216+ 1. Download and extract the zip file
217+ 2. Open Chrome → \`chrome://extensions/\`
218+ 3. Enable "Developer mode" (top right)
219+ 4. Click "Load unpacked" → Select the extracted folder
220+
221+ ### Status
222+ - ✅ All tests passed
223+ - ✅ Build successful
224+ - ✅ Ready for testing
225+
226+ ---
227+ <sub>🤖 Auto-generated by [GitHub Actions](https://github.com/${repo.owner}/${repo.repo}/actions/runs/${runId})</sub>`;
228+
229+ // Check if we already commented
230+ const { data: comments } = await github.rest.issues.listComments({
231+ owner: repo.owner,
232+ repo: repo.repo,
233+ issue_number: prNumber,
234+ });
235+
236+ const botComment = comments.find(comment =>
237+ comment.user.type === 'Bot' &&
238+ comment.body.includes('Extension Build Ready')
239+ );
240+
241+ if (botComment) {
242+ // Delete old comment and create new one for fresh timestamp
243+ await github.rest.issues.deleteComment({
244+ owner: repo.owner,
245+ repo: repo.repo,
246+ comment_id: botComment.id,
247+ });
248+ console.log('Deleted old comment');
249+ }
250+
251+ // Create new comment
252+ await github.rest.issues.createComment({
253+ owner: repo.owner,
254+ repo: repo.repo,
255+ issue_number: prNumber,
256+ body: comment
257+ });
258+ console.log('Created new comment with direct artifact link');
0 commit comments