Files
CV_Site_Nuxt/.gitea/workflows/pr-checker.yml
T
Noel Sabia a061fad9b1
PR Check / Dockerfile lint (droast) (pull_request) Skipped
PR Check / ESLint (pull_request) Successful in 34s
PR Check / Typecheck (pull_request) Successful in 37s
PR Check / Secret scan (gitleaks) (pull_request) Successful in 5s
PR Check / Dependency audit (pull_request) Successful in 9s
PR Check / Security scan (Snyk) (pull_request) Failing after 32s
PR Check / AI code review (opencode) (pull_request) Successful in 8s
fix(ci): JSON-encode review with node instead of jq
The node:22-bookworm image does not ship jq. Also use the renamed
PR_GITEA_TOKEN secret.
2026-10-18 16:08:39 +02:00

229 lines
8.1 KiB
YAML

name: PR Check
on:
pull_request:
types: [opened, synchronize, reopened]
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 ----
lint:
name: ESLint
runs-on: ubuntu-latest
container: node:22-bookworm
steps:
- uses: actions/checkout@v4
- 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: Install dependencies
working-directory: ${{ env.APP_DIR }}
run: pnpm install --frozen-lockfile
- name: Run ESLint
working-directory: ${{ env.APP_DIR }}
run: pnpm lint
# ------------------------------------------------------------ typecheck ---
typecheck:
name: Typecheck
runs-on: ubuntu-latest
container: node:22-bookworm
steps:
- uses: actions/checkout@v4
- 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: Install dependencies
working-directory: ${{ env.APP_DIR }}
run: pnpm install --frozen-lockfile
- 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@v4
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@v4
- 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
continue-on-error: true # advisory: does not block the PR by default
# ------------------------------------------------------- dockerfile lint --
dockerfile-lint:
name: Dockerfile lint (droast)
runs-on: ubuntu-latest
container:
image: immanuwell/droast:1.7.0
# skips until the repo contains a Dockerfile
if: ${{ hashFiles('**/Dockerfile', '**/Dockerfile.*', '**/Containerfile') != '' }}
steps:
- uses: actions/checkout@v4
- name: Lint Dockerfile(s)
run: |
# --no-roast = technical output for CI; --min-severity warning so
# info-level findings don't block the PR
droast --no-roast --min-severity warning .
# ------------------------------------------------------- snyk security ----
snyk:
name: Security scan (Snyk)
runs-on: ubuntu-latest
# 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@v4
- 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
# -------------------------------------------------------- ai code review --
review:
name: AI code review (opencode)
runs-on: ubuntu-latest
container: node:22-bookworm
# Draft PRs don't get a (paid) review yet
if: ${{ !github.event.pull_request.draft }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install opencode CLI
run: curl -fsSL https://opencode.ai/install | bash
env:
# pin the version for reproducible CI, e.g. v1.0.0
OPENCODE_VERSION: latest
- name: Get PR diff
run: |
git diff --merge-base \
"origin/${{ github.base_ref }}" > /tmp/pr.diff
wc -l /tmp/pr.diff
- name: Run opencode review
env:
OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
run: |
# deepseek-v4-pro: DeepSeek's flagship reasoning model - much
# cheaper than claude-sonnet while still thorough for reviews.
opencode run \
--model opencode/deepseek-v4.1-flash \
"You are a strict but pragmatic code reviewer for a pull request.
Review ONLY the diff provided in /tmp/pr.diff. Fetch surrounding files
if you need context from the repo.
Look for: security issues (XSS, injection, auth bypass), leaked
secrets, obvious bugs, breaking changes, performance problems in
Vue/Nuxt code, and missing error handling. Ignore pure style nits -
ESLint already covers those.
End your response with a final verdict line, exactly one of:
VERDICT: APPROVE
VERDICT: REQUEST_CHANGES" \
"$(cat /tmp/pr.diff)" \
2>&1 | tee /tmp/review.md
- name: Post review as PR comment
continue-on-error: true # token missing/expired must not fail the build
env:
GITEA_TOKEN: ${{ secrets.PR_GITEA_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
REPO: ${{ github.repository }}
# Gitea sets GITHUB_API_URL, e.g. https://gitea.example.com/api/v1
run: |
# jq is not in the node image - use node for JSON encoding
BODY=$(node -e 'process.stdout.write(JSON.stringify(require("fs").readFileSync("/tmp/review.md","utf8")))')
curl -sf -X POST \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"body\": ${BODY}}" \
"${GITHUB_API_URL}/repos/${REPO}/issues/${PR_NUMBER}/comments"