-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (45 loc) · 1.57 KB
/
Copy pathknow-code.yml
File metadata and controls
51 lines (45 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
name: know-code
# PR: checkout the tip (not pull/N/merge) and run default verify.
# Push: walk github.event.before..HEAD so landings on main still match
# per-run trailers (origin/main == HEAD has no merge-base range).
on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches: [main]
jobs:
verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
# Default pull_request checkout is a merge commit (no trailers).
# Verify must run on the PR tip that carries Know-Code-Verified.
# On push, head.sha is empty so this is github.sha (the new tip).
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- uses: actions/setup-node@v5
with:
node-version: "22"
cache: npm
- name: Install and build CLI
run: |
npm install
npm run build
npm install -g ./packages/cli
- name: Ensure requireTrailer for CI
run: |
mkdir -p .know-code
printf '{\n "level": "standard",\n "baseBranch": "main",\n "requireTrailer": true\n}\n' > .know-code/config.json
- name: Verify Know-Code-Verified trailer
run: |
if [ "${{ github.event_name }}" = "push" ]; then
BEFORE="${{ github.event.before }}"
if [[ "$BEFORE" =~ ^0+$ ]]; then
echo "know-code: new branch push — skip walk"
exit 0
fi
know-code verify --from "$BEFORE"
else
know-code verify
fi