Skip to content

Commit cff0ad2

Browse files
committed
chore: add workflow to sync webperf skills from webperf-snippets
1 parent a02a567 commit cff0ad2

1 file changed

Lines changed: 128 additions & 0 deletions

File tree

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: Sync WebPerf Skills
2+
3+
on:
4+
schedule:
5+
- cron: '0 9 * * 1' # Every Monday at 9:00 UTC
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
sync:
14+
name: Sync skills from webperf-snippets
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Check out repository
19+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
20+
21+
- name: Get latest release from webperf-snippets
22+
id: upstream
23+
run: |
24+
RELEASE=$(curl -s "https://api.github.com/repos/nucliweb/webperf-snippets/releases/latest")
25+
TAG=$(echo "$RELEASE" | jq -r '.tag_name')
26+
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
27+
echo "Latest webperf-snippets release: $TAG"
28+
29+
- name: Check current synced version
30+
id: current
31+
run: |
32+
VERSION_FILE=".github/webperf-snippets-version"
33+
if [ -f "$VERSION_FILE" ]; then
34+
CURRENT=$(cat "$VERSION_FILE")
35+
else
36+
CURRENT="none"
37+
fi
38+
echo "version=$CURRENT" >> "$GITHUB_OUTPUT"
39+
echo "Current synced version: $CURRENT"
40+
41+
- name: Download and extract skills
42+
if: steps.upstream.outputs.tag != steps.current.outputs.version
43+
env:
44+
TAG: ${{ steps.upstream.outputs.tag }}
45+
run: |
46+
curl -fsSL "https://github.com/nucliweb/webperf-snippets/archive/refs/tags/${TAG}.tar.gz" \
47+
-o /tmp/webperf-snippets.tar.gz
48+
mkdir -p /tmp/webperf-snippets
49+
tar xz -f /tmp/webperf-snippets.tar.gz -C /tmp/webperf-snippets --strip-components=1
50+
cp -r /tmp/webperf-snippets/skills/. skills/
51+
# Adapt tool references from standalone format to MCP server internal format
52+
find skills/ -name "*.md" -exec sed -i 's/`mcp__chrome-devtools__/`/g' {} +
53+
echo "$TAG" > .github/webperf-snippets-version
54+
55+
- name: Check for changes
56+
if: steps.upstream.outputs.tag != steps.current.outputs.version
57+
id: changes
58+
run: |
59+
git add skills/ .github/webperf-snippets-version
60+
if git diff --staged --quiet; then
61+
echo "has_changes=false" >> "$GITHUB_OUTPUT"
62+
echo "No changes detected, skills are already up to date."
63+
else
64+
echo "has_changes=true" >> "$GITHUB_OUTPUT"
65+
git diff --staged --stat
66+
fi
67+
68+
- name: Check for existing PR
69+
if: steps.changes.outputs.has_changes == 'true'
70+
id: existing_pr
71+
env:
72+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73+
TAG: ${{ steps.upstream.outputs.tag }}
74+
run: |
75+
BRANCH="sync/webperf-snippets-${TAG}"
76+
PR=$(gh pr list --head "$BRANCH" --json number --jq '.[0].number // empty')
77+
echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"
78+
echo "number=$PR" >> "$GITHUB_OUTPUT"
79+
80+
- name: Create pull request
81+
if: steps.changes.outputs.has_changes == 'true' && steps.existing_pr.outputs.number == ''
82+
env:
83+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
84+
TAG: ${{ steps.upstream.outputs.tag }}
85+
BRANCH: ${{ steps.existing_pr.outputs.branch }}
86+
run: |
87+
git config user.name "github-actions[bot]"
88+
git config user.email "github-actions[bot]@users.noreply.github.com"
89+
git checkout -b "$BRANCH"
90+
git commit -m "sync: update webperf skills from webperf-snippets ${TAG}"
91+
git push origin "$BRANCH"
92+
93+
SKILLS=$(find skills/ -maxdepth 1 -mindepth 1 -name "webperf*" -type d \
94+
| sort | xargs -I{} basename {} | sed 's/^/- `/' | sed 's/$/`/')
95+
STAT=$(git diff HEAD~1 --stat | tail -1)
96+
97+
{
98+
echo "Automated sync of WebPerf skills from [nucliweb/webperf-snippets](https://github.com/nucliweb/webperf-snippets) release [${TAG}](https://github.com/nucliweb/webperf-snippets/releases/tag/${TAG})."
99+
echo ""
100+
echo "## Skills included"
101+
echo ""
102+
echo "${SKILLS}"
103+
echo ""
104+
echo "## Adaptations"
105+
echo ""
106+
echo "Tool references are automatically adapted from the standalone skill format (\`mcp__chrome-devtools__tool_name\`) to the MCP server internal format (\`tool_name\`) during sync."
107+
echo ""
108+
echo "## Stats"
109+
echo ""
110+
echo "${STAT}"
111+
} > /tmp/pr-body.md
112+
113+
gh pr create \
114+
--title "sync: webperf skills from webperf-snippets ${TAG}" \
115+
--body-file /tmp/pr-body.md
116+
117+
- name: Skip — PR already exists
118+
if: steps.changes.outputs.has_changes == 'true' && steps.existing_pr.outputs.number != ''
119+
env:
120+
TAG: ${{ steps.upstream.outputs.tag }}
121+
run: |
122+
echo "PR already exists for ${TAG} (#${{ steps.existing_pr.outputs.number }}), skipping."
123+
124+
- name: Skip — already up to date
125+
if: steps.upstream.outputs.tag == steps.current.outputs.version
126+
env:
127+
TAG: ${{ steps.upstream.outputs.tag }}
128+
run: echo "Already synced to ${TAG}, nothing to do."

0 commit comments

Comments
 (0)