-
Notifications
You must be signed in to change notification settings - Fork 0
45 lines (37 loc) · 1.38 KB
/
api-contract.yml
File metadata and controls
45 lines (37 loc) · 1.38 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
name: API Contract Validation
on:
pull_request:
branches: [main]
push:
branches: [main]
jobs:
validate-api-contract:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for comparison
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build project
run: npm run build
- name: Check API contract
run: npm run api:check
continue-on-error: false
- name: Comment on PR if API changed
if: failure() && github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.name,
body: '⚠️ **API Contract Violation Detected**\n\nThis PR contains breaking changes to the public API. Please review the changes and update the API report if intentional:\n\n```bash\nnpm run api:extract\ngit add etc/data-models.api.md\ngit commit -m "docs: update API report for breaking changes"\n```\n\nSee CONTRIBUTING.md for more details on API contract management.'
})