Skip to content

Commit 08b5c4f

Browse files
committed
github actions reorganised
1 parent 0fa2397 commit 08b5c4f

File tree

8 files changed

+171
-52
lines changed

8 files changed

+171
-52
lines changed

.github/actions/setup/action.yaml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: 'Setup Action'
2+
description: 'Checkouts the repo, sets up node, and installs dependencies'
3+
runs:
4+
using: 'composite'
5+
steps:
6+
- name: Checkout Repository
7+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
8+
9+
- name: Set up Node.js
10+
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v2
11+
with:
12+
node-version: '18.0'
13+
14+
- name: Cache dependencies
15+
id: cache
16+
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
17+
with:
18+
path: ./node_modules
19+
key: modules-${{ hashFiles('package-lock.json') }}
20+
21+
- name: Install dependencies
22+
if: steps.cache.outputs.cache-hit != 'true'
23+
run: 'npm ci'
24+
shell: bash
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Security Checks
2+
on:
3+
workflow_call:
4+
permissions:
5+
contents: read
6+
jobs:
7+
trivy:
8+
name: Trivy
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout Repository
12+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
13+
14+
- name: Scan repo
15+
uses: aquasecurity/trivy-action@18f2510ee396bbf400402947b394f2dd8c87dbb0 # 0.29.0
16+
with:
17+
scan-type: 'fs'
18+
scan-ref: '.'
19+
scanners: 'vuln,secret,config'
20+
exit-code: '1'
21+
ignore-unfixed: 'true'
22+
severity: 'MEDIUM,HIGH,CRITICAL'
23+
24+
npm-audit:
25+
name: NPM Audit
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout Repository
29+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
30+
31+
- name: Setup
32+
uses: ./.github/actions/setup
33+
34+
- name: Run npm audit
35+
run: npm audit --omit=dev --audit-level=moderate

.github/workflows/_static-checks.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Static Checks
2+
on:
3+
workflow_call:
4+
permissions:
5+
contents: read
6+
jobs:
7+
lint:
8+
name: ESLint Check
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout Repository
12+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
13+
14+
- name: Setup
15+
uses: ./.github/actions/setup
16+
17+
- name: Run linter
18+
run: npm run lint
19+
20+
tsc:
21+
name: TS Types Check
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout Repository
25+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
26+
27+
- name: Setup
28+
uses: ./.github/actions/setup
29+
30+
- name: Run Tsc
31+
run: npm run type-check
32+
33+
build:
34+
name: Build App Check
35+
runs-on: ubuntu-latest
36+
env:
37+
NODE_OPTIONS: "--max_old_space_size=4096"
38+
steps:
39+
- name: Checkout Repository
40+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
41+
42+
- name: Setup
43+
uses: ./.github/actions/setup
44+
45+
- name: Build App
46+
run: npm run build

.github/workflows/_unit-tests.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Unit Tests
2+
permissions:
3+
contents: write
4+
on:
5+
workflow_call:
6+
jobs:
7+
tests:
8+
name: Jest
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout Repository
12+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
13+
14+
- name: Setup
15+
uses: ./.github/actions/setup
16+
17+
- name: Build
18+
run: npm run build
19+
20+
- name: Run tests
21+
run: npm run test
22+

.github/workflows/main.yml

-52
This file was deleted.

.github/workflows/on-pr.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: On PR
2+
permissions: write-all
3+
on:
4+
pull_request:
5+
jobs:
6+
security:
7+
name: Security Checks
8+
uses: ./.github/workflows/_security-checks.yml
9+
10+
static-checks:
11+
name: Static Checks
12+
uses: ./.github/workflows/_static-checks.yml
13+
secrets: inherit
14+
15+
unit-tests:
16+
name: Unit Tests
17+
uses: ./.github/workflows/_unit-tests.yml
18+
secrets: inherit

.github/workflows/on-release.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: On Release
2+
permissions: write-all
3+
on:
4+
release:
5+
types: [published]
6+
jobs:
7+
release:
8+
name: Publish
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout Repository
12+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
13+
14+
- name: Setup
15+
uses: ./.github/actions/setup
16+
17+
- name: Publish
18+
run: npm publish --provenance --access public
19+
env:
20+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
21+
22+
23+

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
"build:esm": "tsc -p tsconfig.prod.json && echo '{\"type\": \"module\"}' > dist/esm/package.json",
4040
"build:cjs": "tsc -p tsconfig.cjs.json && echo '{\"type\": \"commonjs\"}' > dist/cjs/package.json",
4141
"prepack": "npm run build:esm && npm run build:cjs",
42+
"type-check": "npm run type-check:esm && npm run type-check:cjs",
43+
"type-check:esm": "tsc --noEmit -p ./tsconfig.prod.json",
44+
"type-check:cjs": "tsc --noEmit -p ./tsconfig.cjs.json",
4245
"lint": "eslint src/",
4346
"test": "jest",
4447
"start": "npm run server",

0 commit comments

Comments
 (0)