-
Notifications
You must be signed in to change notification settings - Fork 22
72 lines (68 loc) · 2.75 KB
/
Copy pathsync-piapi.yml
File metadata and controls
72 lines (68 loc) · 2.75 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Sync PiAPI API surface
# Periodically detects drift between the versioned PiAPI Manager API contract
# and MCP's committed baseline. It intentionally has no Apidog dependency and
# does not inspect prices. A separate owner-managed MCP token may later be used
# by an approved update workflow; this detector only files a drift issue.
on:
# Scheduled auto-run intentionally disabled. The active PiAPI->MCP sync runs
# from the repo owner's LOCAL scheduler, which reads the Manager contract from
# a local checkout and needs no CI secret. This CI detector requires
# secrets.MCP_SYNC_GITHUB_TOKEN with contents:read on the PRIVATE Manager repo;
# re-enable the weekly `schedule` cron only after that secret is configured,
# otherwise every scheduled run fails on a 404 fetching the private contract.
workflow_dispatch: {}
permissions:
contents: read
issues: write
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Install
run: npm ci || npm install
- name: Build
run: npm run build
- name: Self-test sync engine
run: npm run test:sync
- name: Diff PiAPI contract vs committed baseline
id: diff
env:
PIAPI_SYNC_SOURCE: github
PIAPI_CONTRACT_GITHUB_TOKEN: ${{ secrets.MCP_SYNC_GITHUB_TOKEN }}
run: |
set +e
node dist/sync/cli.js report-file sync-report.md
code=$?
echo "exit_code=$code" >> "$GITHUB_OUTPUT"
echo "----- report -----"
cat sync-report.md
if [ "$code" = "1" ]; then exit 1; fi
exit 0
- name: Open/update drift issue
if: steps.diff.outputs.exit_code == '2'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const body = fs.readFileSync('sync-report.md', 'utf8');
const title = 'PiAPI → MCP drift detected';
const { data: issues } = await github.rest.issues.listForRepo({
owner: context.repo.owner, repo: context.repo.repo, state: 'open', labels: 'piapi-sync',
});
if (issues.length) {
await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: issues[0].number, body });
} else {
await github.rest.issues.create({ owner: context.repo.owner, repo: context.repo.repo, title, body, labels: ['piapi-sync'] });
}
- name: Upload report artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: sync-report
path: sync-report.md
if-no-files-found: ignore