Skip to content

Commit 6c60adf

Browse files
committed
Add GitHub CI Actions
Close #7.
1 parent c220410 commit 6c60adf

File tree

7 files changed

+154
-1
lines changed

7 files changed

+154
-1
lines changed

‎.github/actions/setup/action.yml‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Setup Node Environment
2+
description: Prepare repository, Node, and dependencies.
3+
runs:
4+
using: composite
5+
steps:
6+
- uses: actions/setup-node@v4
7+
with:
8+
node-version: latest
9+
cache: npm
10+
- shell: bash
11+
run: npm ci

‎.github/workflows/build.yml‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
paths:
7+
- '**/*.ts'
8+
- '**/*.js'
9+
- 'manifest.json'
10+
- 'package.json'
11+
- 'package-lock.json'
12+
pull_request:
13+
paths:
14+
- '**/*.ts'
15+
- '**/*.js'
16+
- 'manifest.json'
17+
- 'package.json'
18+
- 'package-lock.json'
19+
workflow_dispatch:
20+
21+
jobs:
22+
build:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: ./.github/actions/setup
27+
- run: npm run build
28+
- name: Upload Firefox artifact
29+
uses: actions/upload-artifact@v4
30+
with:
31+
name: dist-firefox
32+
path: dist/firefox

‎.github/workflows/eslint.yml‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: ESLint
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
paths:
7+
- '**/*.ts'
8+
- '**/*.js'
9+
- 'eslint.config.js'
10+
- 'package.json'
11+
- 'package-lock.json'
12+
pull_request:
13+
paths:
14+
- '**/*.ts'
15+
- '**/*.js'
16+
- 'eslint.config.js'
17+
- 'package.json'
18+
- 'package-lock.json'
19+
workflow_dispatch:
20+
21+
jobs:
22+
eslint:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: ./.github/actions/setup
27+
- run: npx eslint .

‎.github/workflows/stylelint.yml‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Stylelint
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
paths:
7+
- '**/*.css'
8+
- '.stylelintrc.json'
9+
- 'package.json'
10+
- 'package-lock.json'
11+
pull_request:
12+
paths:
13+
- '**/*.css'
14+
- '.stylelintrc.json'
15+
- 'package.json'
16+
- 'package-lock.json'
17+
workflow_dispatch:
18+
19+
jobs:
20+
stylelint:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
- uses: ./.github/actions/setup
25+
- run: npx stylelint '**/*.css'

‎.github/workflows/tests.yml‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
paths:
7+
- '**/*.ts'
8+
- '**/*.js'
9+
- 'manifest.json'
10+
- 'package.json'
11+
- 'package-lock.json'
12+
pull_request:
13+
paths:
14+
- '**/*.ts'
15+
- '**/*.js'
16+
- 'manifest.json'
17+
- 'package.json'
18+
- 'package-lock.json'
19+
workflow_dispatch:
20+
21+
jobs:
22+
tests:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: ./.github/actions/setup
27+
- run: npm test

‎.github/workflows/webext-lint.yml‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: WebExt Lint
2+
3+
permissions:
4+
actions: read
5+
contents: read
6+
7+
on:
8+
workflow_run:
9+
workflows: [Build]
10+
types: [completed]
11+
12+
jobs:
13+
webext-lint:
14+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
ref: ${{ github.event.workflow_run.head_sha }}
20+
- uses: ./.github/actions/setup
21+
- name: Download Firefox artifact
22+
uses: actions/download-artifact@v4
23+
with:
24+
name: dist-firefox
25+
run-id: ${{ github.event.workflow_run.id }}
26+
path: dist
27+
- name: Lint Firefox build
28+
run: npx web-ext lint dist/firefox

‎scripts/build.js‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,12 @@ async function buildIcon(icon, size, distDir) {
294294
// https://bugs.chromium.org/p/chromium/issues/detail?id=29683.
295295
console.log(
296296
`Converting ${svgIcon} to PNG and writing to dist`);
297+
const puppeteerLaunchOptions = {executablePath};
298+
// Needed for puppeteer to work in GitHub workflows.
299+
if (process.env.CI) puppeteerLaunchOptions.args = ['--no-sandbox'];
297300
const png =
298301
await svg2png(optimizedSVGStr, {
299-
launch: {executablePath},
302+
launch: puppeteerLaunchOptions,
300303
width: size,
301304
height: size
302305
});

0 commit comments

Comments
 (0)