Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Build Extension Packages

on:
push:
branches: [main]
paths-ignore:
- "README.md"
- "LICENSE"
pull_request:
branches: [main]
paths-ignore:
- "README.md"
- "LICENSE"
workflow_dispatch: # Allows manual re-run from GitHub UI

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: "npm"

- name: Install dependencies
run: npm ci

- name: Build extension packages
run: npm run build

- name: Upload Chrome extension artifact
uses: actions/upload-artifact@v4
with:
name: carbon-visualizer-chrome
path: build/carbon-visualizer-chrome.zip
retention-days: 30

- name: Upload Firefox extension artifact
uses: actions/upload-artifact@v4
with:
name: carbon-visualizer-firefox
path: build/carbon-visualizer-firefox.zip
retention-days: 30

- name: Comment PR with artifact links
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});

const botComment = comments.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('📦 Extension packages built successfully!')
);

const commentBody = `📦 Extension packages built successfully!

**[Download your Chrome and Firefox extension packages](https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId})**`;

if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: commentBody
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: commentBody
});
}

- name: Notify on failure
if: failure()
run: |
echo "❌ Build failed! Check the logs above for details."