Files
CV_Site_Nuxt/.gitea/workflows/pr-checker.yml
Noel d63360b980
PR Check / Security scan (Snyk) (pull_request) Skipped
PR Check / Lint + typecheck (pull_request) Successful in 1m12s
PR Check / Secret scan (gitleaks) (pull_request) Successful in 6s
PR Check / Dependency audit (pull_request) Successful in 9s
PR Check / Dockerfile lint (droast) (pull_request) Successful in 5s
chore(deps): update actions/checkout action to v7
2026-11-05 04:05:28 +00:00

232 lines
9.5 KiB
YAML

name: PR Check
on:
pull_request:
types: [opened, synchronize, reopened]
# manual trigger: the only way the paused snyk job below can run
workflow_dispatch:
concurrency:
group: pr-check-${{ github.event.pull_request.number }}
cancel-in-progress: true
env:
# The Gitea repo root IS the Nuxt app (CV_Website/CV_Site_Nuxt), so all
# app commands run from the workspace root. If you ever move the app into
# a subdirectory, change this to the subdirectory path.
APP_DIR: .
jobs:
# ------------------------------------------------------ lint + typecheck --
# One job, not two: both checks use the same image, the same lockfile and
# the same install, so splitting them doubled the install work (and, on the
# 2 vCPU runner, the CPU contention). They still report as separate steps,
# so a failure says which check failed.
checks:
name: Lint + typecheck
runs-on: ubuntu-latest
container: node:22-bookworm
steps:
- uses: actions/checkout@v7
- uses: pnpm/action-setup@v4
with:
# match the pnpm major version used locally (v11.x) - older pnpm
# rejects our config-only pnpm-workspace.yaml ("packages field
# missing or empty")
version: 11
- name: Resolve pnpm store and lockfile hash
id: pnpm
working-directory: ${{ env.APP_DIR }}
run: |
# hashFiles() evaluates empty in this act runner, so the cache key
# is built from a real sha256 in a shell step instead. The store
# directory's own name is the layout version (store/v11 here), so
# it is in the key: a store from another pnpm major is unusable.
store="$(pnpm store path --silent)"
echo "store=$store" >> "$GITHUB_OUTPUT"
echo "layout=$(basename "$store")" >> "$GITHUB_OUTPUT"
echo "lockfile=$(sha256sum pnpm-lock.yaml | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
- name: Restore pnpm store
# v4.1.x, not v4.2+: the runner's cache server may only speak the v1
# API (Gitea runner 2.x). v4.1 works on both v1-only and v3 runners.
# A cache outage must not turn into a red PR: install still works
# without the store, just slower.
continue-on-error: true
uses: actions/cache@v6.1.0
with:
path: ${{ steps.pnpm.outputs.store }}
key: pnpm-store-${{ runner.os }}-${{ steps.pnpm.outputs.layout }}-${{ steps.pnpm.outputs.lockfile }}
restore-keys: |
pnpm-store-${{ runner.os }}-${{ steps.pnpm.outputs.layout }}-
- name: Install dependencies
working-directory: ${{ env.APP_DIR }}
run: pnpm install --frozen-lockfile
- name: Run ESLint
working-directory: ${{ env.APP_DIR }}
run: pnpm lint
- name: Typecheck (vue-tsc)
working-directory: ${{ env.APP_DIR }}
run: pnpm typecheck
# -------------------------------------------------------------- secrets ---
secrets:
name: Secret scan (gitleaks)
runs-on: ubuntu-latest
# plain node image: the gitleaks container image has no node, which
# breaks node-based actions like actions/checkout
container: node:22-bookworm
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0 # gitleaks scans the full history
- name: Install gitleaks
run: |
echo "Runner arch: $(uname -m)"
case "$(uname -m)" in
x86_64) GITLEAKS_ARCH=x64 ;;
aarch64) GITLEAKS_ARCH=arm64 ;;
*) echo "unsupported arch: $(uname -m)" && exit 1 ;;
esac
curl -fsSL -o /tmp/gitleaks.tar.gz \
"https://github.com/gitleaks/gitleaks/releases/download/v8.28.0/gitleaks_8.28.0_linux_${GITLEAKS_ARCH}.tar.gz"
tar -xzf /tmp/gitleaks.tar.gz -C /usr/local/bin gitleaks
gitleaks version
- name: Scan for leaked secrets
run: gitleaks detect --source . --redact --verbose
# Already-committed secrets that you've accepted? Add a .gitleaksignore
# file listing their fingerprints instead of disabling the check.
# ----------------------------------------------------------- dependency ---
audit:
name: Dependency audit
runs-on: ubuntu-latest
container: node:22-bookworm
steps:
- uses: actions/checkout@v7
- uses: pnpm/action-setup@v4
with:
# match the pnpm major version used locally (v11.x) - older pnpm
# rejects our config-only pnpm-workspace.yaml ("packages field
# missing or empty")
version: 11
- name: Audit dependencies for known vulnerabilities
working-directory: ${{ env.APP_DIR }}
run: pnpm audit --prod --audit-level moderate
# blocks the PR on vulnerabilities - re-add `continue-on-error: true`
# here only if a CVE fix is genuinely blocked upstream, never to
# make a red pipeline green
# ------------------------------------------------------- dockerfile lint --
dockerfile-lint:
name: Dockerfile lint (droast)
runs-on: ubuntu-latest
# droast's own container image ships no node (actions/checkout would
# fail with exit 127 - same as the gitleaks image), so run the droast
# binary in the multi-arch node image instead
container: node:22-bookworm
steps:
- uses: actions/checkout@v7
- name: Install droast
run: |
case "$(uname -m)" in
x86_64) DROAST_ASSET=droast-linux-x86_64; DROAST_SHA=cadb963a040ba2e68641af764f794e5d4fb3371bb9b92255fa5027060b08ea6e ;;
aarch64) DROAST_ASSET=droast-linux-arm64; DROAST_SHA=0800e80d11f668615fc87750f58809b56bedca83ec6d8a539daa56f42da64bc3 ;;
*) echo "unsupported arch: $(uname -m)" && exit 1 ;;
esac
curl -fsSL -o /usr/local/bin/droast \
"https://github.com/immanuwell/dockerfile-roast/releases/download/1.7.0/${DROAST_ASSET}"
# verify against the pinned hash checked into this workflow
# (fetching the checksum from the same release as the binary
# would be trust-on-first-use and prove nothing)
echo "${DROAST_SHA} /usr/local/bin/droast" | sha256sum -c -
chmod +x /usr/local/bin/droast
droast --version
- name: Discover Dockerfiles
id: discover
# shell check instead of hashFiles: the act runner's hashFiles
# evaluation returned empty and silently skipped the job even when
# Dockerfiles existed
run: |
# Discovery: -print -quit instead of `| head -n 1` - head can
# SIGPIPE find (exit 141) when multiple Dockerfiles match
found="$(find . \
-path ./.git -prune -o -path ./node_modules -prune -o \
-type f \( -iname 'Dockerfile*' -o -iname '*dockerfile' -o -iname 'Containerfile*' \) \
-print -quit)"
if [ -n "$found" ]; then
echo "found=true" >> "$GITHUB_OUTPUT"
echo "Dockerfile found: $found"
else
echo "found=false" >> "$GITHUB_OUTPUT"
echo "No Dockerfile in repo - nothing to lint"
fi
- name: Lint Dockerfile(s)
if: ${{ steps.discover.outputs.found == 'true' }}
run: |
# --no-roast = technical output for CI; --min-severity warning so
# info-level findings don't block the PR
# lint exactly the tree the discovery step sees: prune node_modules
# and .git so vendored Dockerfiles in dependencies cannot produce
# findings on third-party code
find . \
-path ./.git -prune -o -path ./node_modules -prune -o \
-type f \( -iname 'Dockerfile*' -o -iname '*dockerfile' -o -iname 'Containerfile*' \) \
-print0 | xargs -0 -r droast --no-roast --min-severity warning
# ------------------------------------------------------- snyk security ----
# PAUSED: Snyk free plan only includes ~100 test credits/month, which the
# pipeline would burn through quickly (2 tests per PR push).
# Paused the actionlint-clean way: the job only runs on manual
# (workflow_dispatch) triggers, so pushes and PRs never burn credits.
# To re-enable fully, delete the if: line below. Consider also running
# this job only on PRs marked "ready for review" or on a weekly schedule
# instead of on every push.
snyk:
name: Security scan (Snyk)
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch'
# snyk/snyk:node is amd64-only ("no matching manifest for linux/arm64"),
# so install the CLI via npm in the multi-arch node image instead
container: node:22-bookworm
steps:
- uses: actions/checkout@v7
- name: Install Snyk CLI
run: npm install -g snyk@1 && snyk --version
- name: Snyk dependency scan
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
working-directory: ${{ env.APP_DIR }}
run: |
# --all-projects: required because pnpm-workspace.yaml exists -
# without it Snyk errors with SNYK-CLI-0000
# --strict-out-of-sync: fails if the lockfile doesn't match package.json
snyk test \
--all-projects \
--severity-threshold=high \
--strict-out-of-sync=true
- name: Snyk Code scan (SAST)
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
working-directory: ${{ env.APP_DIR }}
run: |
# static analysis of our own source code (XSS, injection, ...)
# Dockerfile/base image checks are covered by the droast job
snyk code test \
--severity-threshold=high