diff --git a/.gitea/workflows/pr-checker.yml b/.gitea/workflows/pr-checker.yml new file mode 100644 index 0000000..956e650 --- /dev/null +++ b/.gitea/workflows/pr-checker.yml @@ -0,0 +1,189 @@ +name: PR Check + +on: + pull_request: + types: [opened, synchronize, reopened] + +concurrency: + group: pr-check-${{ github.event.pull_request.number }} + cancel-in-progress: true + +env: + APP_DIR: CV_Site_Nuxt + +jobs: + # ---------------------------------------------------------------- lint ---- + lint: + name: ESLint + runs-on: ubuntu-latest + container: node:22-bookworm + steps: + - uses: actions/checkout@v4 + + - uses: pnpm/action-setup@v4 + with: + version: 9 + + - 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: + version: 9 + + - 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 + container: + image: gitleaks/gitleaks:latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # gitleaks scans the full history + + - 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: + version: 9 + + - 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 + container: + image: snyk/snyk:node + steps: + - uses: actions/checkout@v4 + + - name: Snyk dependency scan + env: + SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} + working-directory: ${{ env.APP_DIR }} + run: | + # --strict-out-of-sync: fails if the lockfile doesn't match package.json + snyk test \ + --severity-threshold=high \ + --strict-out-of-sync=true + + - name: Snyk Dockerfile / base image check + env: + SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} + if: ${{ hashFiles(format('{0}/Dockerfile', env.APP_DIR)) != '' }} + working-directory: ${{ env.APP_DIR }} + run: snyk test --docker --file=Dockerfile --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: | + opencode run \ + --model anthropic/claude-sonnet-4-5 \ + "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.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: | + BODY=$(jq -Rs . < /tmp/review.md) + 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" diff --git a/.gitea/workflows/release-please.yml b/.gitea/workflows/release-please.yml new file mode 100644 index 0000000..2f8395a --- /dev/null +++ b/.gitea/workflows/release-please.yml @@ -0,0 +1,19 @@ +on: + push: + branches: + - main + +permissions: + contents: write + pull-requests: write + +name: release-please + +jobs: + release-please: + runs-on: ubuntu-latest + steps: + - uses: joaquinjsb/gitea-release-please-action@v4 + with: + token: ${{ secrets.RELEASE_PLEASE_TOKEN_CV_SITE_NUXT }} + release-type: simple