-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (75 loc) · 3.26 KB
/
Copy pathllm-exports-sync.yml
File metadata and controls
85 lines (75 loc) · 3.26 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
73
74
75
76
77
78
79
80
81
82
83
84
85
# Deterministic sync from .cursor to .llm/exports (see scripts/llm/ and docs/development/llm/).
# Does not use cloud LLM APIs. Export is plain Node (no root npm install); see package.json llm:exports:sync.
# PRs to develop are not gated on .llm/exports matching; after merge, this workflow (push to develop) updates branch `llm` and its rolling PR. Use `npm run llm:exports:check` locally if you want to assert a branch is in sync.
name: LLM exports sync
on:
push:
branches: [develop]
paths:
- ".cursor/**"
- ".cursorrules"
- ".cursorignore"
- "scripts/llm/**"
workflow_dispatch: {}
concurrency:
group: llm-exports-${{ github.ref }}
cancel-in-progress: true
jobs:
publish_llm_pr:
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/develop' && !contains(github.event.head_commit.message, '[bot]'))
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout develop
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
ref: develop
fetch-depth: 0
- name: Use Node
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
- name: Generate exports
run: node scripts/llm/export-from-cursor.mjs sync
- name: Stage export tree
# peter-evans/create-pull-request respects .gitignore; machine output is ignored locally
# — force-add gitignored export paths (same staging as local `llm:exports:check` would use)
run: |
set -e
git add -A -f -- .llm/exports
- name: Create or update llm PR
id: cpr
uses: peter-evans/create-pull-request@v8
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: llm
base: develop
add-paths: .llm/exports
commit-message: "chore(llm): sync .llm/exports from .cursor"
title: "chore(llm): sync .llm/exports from .cursor"
body: |
Automated LLM export sync from `.cursor` + `.cursorrules`.
- Source of truth remains `.cursor/**` and `.cursorrules`
- Generated: `.llm/exports/**` (including ignored paths, staged on the workflow runner for the PR)
labels: |
llm
delete-branch: false
- name: Keep only the latest open llm PR
if: always()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
prs_json=$(gh api "repos/${{ github.repository }}/pulls?state=open&head=${{ github.repository_owner }}:llm&base=develop&per_page=100")
mapfile -t prs < <(node -e "const prs=JSON.parse(process.argv[1]||'[]'); prs.sort((a,b)=>new Date(b.updated_at)-new Date(a.updated_at)); for (const pr of prs) console.log(pr.number);" "$prs_json")
if [ "${#prs[@]}" -le 1 ]; then
echo "No duplicate llm PRs to close."
exit 0
fi
echo "Keeping PR #${prs[0]} and closing ${#prs[@]}-1 duplicate(s)."
for n in "${prs[@]:1}"; do
gh pr close "$n" --repo "${{ github.repository }}" --comment "Closing duplicate llm automation PR; branch llm reuses a single rolling PR into develop."
done