-
Notifications
You must be signed in to change notification settings - Fork 7
163 lines (142 loc) · 6.25 KB
/
Copy pathsync-skills.yml
File metadata and controls
163 lines (142 loc) · 6.25 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
name: Sync skills from PostHog release
on:
schedule:
- cron: '0 12 * * *' # Daily at midday UTC
workflow_dispatch:
inputs:
ref:
description: 'Branch to sync skills into'
required: false
default: ''
jobs:
sync-skills:
runs-on: ubuntu-latest
steps:
- name: Generate GitHub App token
id: app-token
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0
with:
app-id: ${{ secrets.GH_APP_AI_PLUGIN_RELEASER_APP_ID }}
private-key: ${{ secrets.GH_APP_AI_PLUGIN_RELEASER_PRIVATE_KEY }}
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ github.event.inputs.ref || github.ref }}
token: ${{ steps.app-token.outputs.token }}
- name: Download skills from PostHog release
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
gh release download agent-skills-latest \
--repo PostHog/posthog \
--pattern 'skills.zip' \
--dir /tmp
- name: Download skills from context-mill
run: |
curl -fsSL --retry 2 --retry-delay 3 \
-o /tmp/context-mill.zip \
"https://github.com/PostHog/context-mill/releases/latest/download/skills-mcp-resources.zip"
- name: Sync skills directory
run: |
MANIFEST="skills/.sync-manifest"
# Delete only previously-synced skills (listed in manifest)
if [ -f "$MANIFEST" ]; then
while IFS= read -r dir; do
[ -n "$dir" ] && rm -rf "skills/$dir"
done < "$MANIFEST"
fi
# Extract PostHog release skills
unzip -o /tmp/skills.zip -d skills/
# Extract context-mill skills (nested zips, strip omnibus- prefix)
tmp_cm=$(mktemp -d)
cm_manifest=$(mktemp)
unzip -q -o /tmp/context-mill.zip -d "$tmp_cm"
while read -r inner_zip; do
skill_name="$(basename "$inner_zip" .zip)"
skill_name="${skill_name#omnibus-}"
echo "$skill_name" >> "$cm_manifest"
mkdir -p "skills/$skill_name"
unzip -q -o "$inner_zip" -d "skills/$skill_name"
find "skills/$skill_name" -name 'SKILL.md' -type f -exec sed -i 's/^\(name: *\)omnibus-/\1/' {} +
find "skills/$skill_name" -name 'SKILL.md' -type f -exec sed -i '/^ version: .*/d' {} +
done < <(find "$tmp_cm" -name 'omnibus-*.zip' -type f)
rm -rf "$tmp_cm"
# Rebuild manifest from both sources
{
zipinfo -1 /tmp/skills.zip | grep '/' | cut -d'/' -f1
cat "$cm_manifest"
} | sort -u > "$MANIFEST"
rm -f "$cm_manifest"
# Reconcile: remove any directory not in the new manifest
# (catches orphans from past manual edits or partial deletions)
for d in skills/*/; do
[ -d "$d" ] || continue
name=$(basename "$d")
grep -qFx "$name" "$MANIFEST" || rm -rf "$d"
done
- name: Check for changes and bump version
id: check
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
git add -A skills/ commands/*.toml gemini-extension.json
if git diff --cached --quiet; then
echo "No changes detected."
echo "has_changes=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "has_changes=true" >> "$GITHUB_OUTPUT"
# Bump patch version in plugin manifests
for f in .claude-plugin/plugin.json .cursor-plugin/plugin.json .codex-plugin/plugin.json gemini-extension.json; do
if [ -f "$f" ]; then
jq '.version |= (split(".") | .[2] = (.[2] | tonumber + 1 | tostring) | join("."))' "$f" > "$f.tmp" && mv "$f.tmp" "$f"
fi
done
# Regenerate Gemini TOML command files from MD sources
if [ -x scripts/generate-gemini-commands.sh ]; then
bash scripts/generate-gemini-commands.sh
fi
# Extract version info from both sources
PH_BODY=$(gh release view agent-skills-latest --repo PostHog/posthog --json body -q '.body' 2>/dev/null || echo "")
PH_VERSION=$(echo "$PH_BODY" | grep -oE 'agent-skills-v[0-9.]+' | head -1)
CM_TAG=$(gh release view --repo PostHog/context-mill --json tagName -q '.tagName' 2>/dev/null || echo "")
VERSIONS=""
[ -n "$PH_VERSION" ] && VERSIONS="$PH_VERSION"
[ -n "$CM_TAG" ] && VERSIONS="${VERSIONS:+$VERSIONS, }context-mill@$CM_TAG"
VERSIONS="${VERSIONS:-latest}"
echo "commit_message=chore: sync skills ($VERSIONS)" >> "$GITHUB_OUTPUT"
- name: Create sync branch
if: steps.check.outputs.has_changes == 'true'
id: branch
run: |
BRANCH="chore/sync-skills-$(date +%Y%m%d-%H%M%S)"
git checkout -b "$BRANCH"
git push origin "$BRANCH"
echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"
echo "base=$BASE_REF" >> "$GITHUB_OUTPUT"
env:
BASE_REF: ${{ github.event.inputs.ref || github.ref_name }}
- name: Commit and push
if: steps.check.outputs.has_changes == 'true'
uses: planetscale/ghcommit-action@25309d8005ac7c3bcd61d3fe19b69e0fe47dbdde # v0.2.20
with:
commit_message: ${{ steps.check.outputs.commit_message }}
repo: ${{ github.repository }}
branch: ${{ steps.branch.outputs.branch }}
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
- name: Create PR with auto-merge
if: steps.check.outputs.has_changes == 'true'
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
COMMIT_MESSAGE: ${{ steps.check.outputs.commit_message }}
BASE_REF: ${{ steps.branch.outputs.base }}
HEAD_REF: ${{ steps.branch.outputs.branch }}
run: |
PR_URL=$(gh pr create \
--base "$BASE_REF" \
--head "$HEAD_REF" \
--title "$COMMIT_MESSAGE" \
--body "Automated skill sync from PostHog release and context-mill." \
--reviewer "PostHog/team-posthog-ai")
gh pr merge "$PR_URL" --auto --squash