Skip to content

Commit 2f6c841

Browse files
committed
feat: poll agent-skills releases for sync
1 parent dc481cd commit 2f6c841

2 files changed

Lines changed: 38 additions & 18 deletions

File tree

.github/workflows/sync-agent-skills.yml

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
name: Sync agent-skills release
22

33
on:
4-
repository_dispatch:
5-
types:
6-
- agent_skills_release_published
4+
schedule:
5+
- cron: "17 */6 * * *"
76
workflow_dispatch:
87
inputs:
98
release_tag:
10-
description: Release tag from supabase/agent-skills (for example, v0.1.0)
11-
required: true
9+
description: Optional release tag from supabase/agent-skills (for example, v0.1.0). Defaults to the latest release.
10+
required: false
1211
release_version:
1312
description: Optional semver corresponding to the release tag
1413
required: false
@@ -31,18 +30,37 @@ jobs:
3130
- name: Resolve release metadata
3231
id: release
3332
shell: bash
33+
env:
34+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3435
run: |
35-
if [ "${{ github.event_name }}" = "repository_dispatch" ]; then
36-
echo "tag=${{ github.event.client_payload.release_tag }}" >> "$GITHUB_OUTPUT"
37-
echo "version=${{ github.event.client_payload.release_version }}" >> "$GITHUB_OUTPUT"
38-
echo "sha=${{ github.event.client_payload.commit_sha }}" >> "$GITHUB_OUTPUT"
36+
if [ -n "${{ inputs.release_tag }}" ]; then
37+
TAG="${{ inputs.release_tag }}"
38+
VERSION="${{ inputs.release_version }}"
39+
SHA="${{ inputs.commit_sha }}"
3940
else
40-
echo "tag=${{ inputs.release_tag }}" >> "$GITHUB_OUTPUT"
41-
echo "version=${{ inputs.release_version }}" >> "$GITHUB_OUTPUT"
42-
echo "sha=${{ inputs.commit_sha }}" >> "$GITHUB_OUTPUT"
41+
TAG=$(gh release view --repo supabase/agent-skills --json tagName --jq '.tagName')
42+
VERSION="${TAG#v}"
43+
SHA=$(gh release view "${TAG}" --repo supabase/agent-skills --json targetCommitish --jq '.targetCommitish')
44+
fi
45+
46+
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
47+
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
48+
echo "sha=${SHA}" >> "$GITHUB_OUTPUT"
49+
50+
- name: Check whether sync is needed
51+
id: should_sync
52+
shell: bash
53+
run: |
54+
CURRENT_TAG=$(jq -r '.source_release // ""' skills/.upstream.json)
55+
56+
if [ "${CURRENT_TAG}" = "${{ steps.release.outputs.tag }}" ]; then
57+
echo "changed=false" >> "$GITHUB_OUTPUT"
58+
else
59+
echo "changed=true" >> "$GITHUB_OUTPUT"
4360
fi
4461
4562
- name: Download skill release assets
63+
if: ${{ steps.should_sync.outputs.changed == 'true' }}
4664
env:
4765
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4866
run: |
@@ -54,14 +72,16 @@ jobs:
5472
--pattern "supabase-postgres-best-practices.tar.gz"
5573
5674
- name: Replace vendored skills
75+
if: ${{ steps.should_sync.outputs.changed == 'true' }}
5776
run: |
5877
rm -rf skills/supabase skills/supabase-postgres-best-practices
59-
mkdir -p skills/supabase skills/supabase-postgres-best-practices
78+
mkdir -p skills
6079
61-
tar -xzf /tmp/agent-skills-release/supabase.tar.gz -C skills/supabase
62-
tar -xzf /tmp/agent-skills-release/supabase-postgres-best-practices.tar.gz -C skills/supabase-postgres-best-practices
80+
tar -xzf /tmp/agent-skills-release/supabase.tar.gz -C skills
81+
tar -xzf /tmp/agent-skills-release/supabase-postgres-best-practices.tar.gz -C skills
6382
6483
- name: Update upstream metadata
84+
if: ${{ steps.should_sync.outputs.changed == 'true' }}
6585
shell: bash
6686
run: |
6787
SYNCED_AT=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
@@ -84,6 +104,7 @@ jobs:
84104
EOF
85105
86106
- name: Create pull request
107+
if: ${{ steps.should_sync.outputs.changed == 'true' }}
87108
uses: peter-evans/create-pull-request@v7
88109
with:
89110
branch: chore/sync-agent-skills-${{ steps.release.outputs.tag }}
@@ -102,4 +123,3 @@ jobs:
102123
103124
## Notes
104125
- generated by the `sync-agent-skills` workflow
105-

AGENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ The shipped skills in `skills/` are intended to be real vendored files.
8484

8585
- The source of truth for skill content is `supabase/agent-skills`.
8686
- This repo consumes release assets from `supabase/agent-skills`, not a submodule or symlink.
87-
- The sync workflow expects the upstream release to publish:
87+
- The sync workflow polls the latest GitHub release from `supabase/agent-skills` and expects it to publish:
8888
- `supabase.tar.gz`
8989
- `supabase-postgres-best-practices.tar.gz`
9090
- Synced provenance is tracked in `skills/.upstream.json`.
9191

92-
If skills are updated upstream, use the sync workflow or the repository dispatch event to vendor them into this repo as normal files and review the resulting PR here before merge.
92+
If skills are updated upstream, let the scheduled sync workflow pick up the new release or run the workflow manually with a specific `release_tag` to vendor them into this repo as normal files and review the resulting PR here before merge.

0 commit comments

Comments
 (0)