Skip to content

Commit dc145cf

Browse files
authored
chore: add GH workflows security, static checks, dependabot (#19)
* chore: add GH static checks workflows and dependabot * chore: add husky precommit * chore: add husky, lint-staged precommit * chore: add security workflow checks * fix: husky permission * fix: husky config
1 parent 89a2962 commit dc145cf

File tree

9 files changed

+789
-4
lines changed

9 files changed

+789
-4
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: 'lts/*'
13+
14+
- name: Cache dependencies
15+
id: cache
16+
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
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

.github/dependabot.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: 'npm' # See documentation for possible values
9+
directory: '/' # Location of package manifests
10+
schedule:
11+
interval: 'weekly'
12+
day: 'saturday'
13+
versioning-strategy: increase
14+
- package-ecosystem: 'github-actions'
15+
directory: '/'
16+
schedule:
17+
interval: 'weekly'
18+
day: 'saturday'
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Security Checks
2+
on:
3+
workflow_call:
4+
jobs:
5+
trivy:
6+
name: Trivy
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout Repository
10+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
11+
12+
- name: Scan repo
13+
uses: aquasecurity/trivy-action@915b19bbe73b92a6cf82a1bc12b087c9a19a5fe2 # 0.28.0
14+
with:
15+
scan-type: 'fs'
16+
scan-ref: '.'
17+
scanners: 'vuln,secret,config'
18+
exit-code: '1'
19+
ignore-unfixed: 'true'
20+
severity: 'MEDIUM,HIGH,CRITICAL'
21+
22+
npm-audit:
23+
name: NPM Audit
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout Repository
27+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
28+
29+
- name: Set up Node.js
30+
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v2
31+
with:
32+
node-version: 'lts/*'
33+
34+
- name: Run npm audit
35+
run: npm audit --omit=dev --audit-level=moderate

.github/workflows/_static-checks.yml

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

.github/workflows/on-pr.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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

.husky/pre-commit

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx lint-staged

lint-staged.config.mjs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* @type {import("lint-staged").Config}
3+
*/
4+
export default {
5+
"**/*.{js,jsx,ts,tsx,mjs,cjs}": [
6+
"npx prettier --write",
7+
"npx eslint --fix",
8+
"bash -c tsc -p ./tsconfig.app.json --noEmit",
9+
],
10+
};

0 commit comments

Comments
 (0)