-
Notifications
You must be signed in to change notification settings - Fork 1
feat: docs-as-skillz #115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sarahxsanders
wants to merge
4
commits into
main
Choose a base branch
from
docs-as-skills
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: docs-as-skillz #115
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,184 @@ | ||
| name: Sync PostHog Docs Skills | ||
|
|
||
| # Triggered by posthog.com after a successful deploy, nightly as a fallback, | ||
| # or manually. Fetches posthog.com/llms.txt, regenerates the posthog-docs | ||
| # skill directories and docs-skill-menu.json, and cuts a new release if anything changed | ||
|
|
||
| on: | ||
| repository_dispatch: | ||
|
sarahxsanders marked this conversation as resolved.
Outdated
|
||
| types: [posthog-docs-deployed] | ||
| schedule: | ||
| - cron: '0 2 * * *' | ||
| workflow_dispatch: | ||
|
|
||
| # One sync at a time — if posthog.com deploys rapidly, cancel the queued run | ||
| # and let the latest trigger win. | ||
| concurrency: | ||
| group: sync-docs-skills | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| sync: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | ||
| with: | ||
| fetch-depth: 0 # Full history needed for version tag lookup | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 | ||
| with: | ||
| node-version: 'lts/*' | ||
|
|
||
| - name: Setup pnpm | ||
| uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4 | ||
| with: | ||
| version: 9 | ||
|
|
||
| - name: Install dependencies | ||
| run: pnpm install --frozen-lockfile | ||
|
|
||
| - name: Determine next version | ||
|
sarahxsanders marked this conversation as resolved.
Outdated
|
||
| id: version | ||
| run: | | ||
| LATEST_TAG=$(git tag -l | grep -v '^latest$' | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -n 1) | ||
| if [ -z "$LATEST_TAG" ]; then | ||
| LATEST_TAG="v0.0.0" | ||
| fi | ||
| echo "Latest semver tag: ${LATEST_TAG}" | ||
| LATEST_VERSION=${LATEST_TAG#v} | ||
| IFS='.' read -r -a VERSION_PARTS <<< "$LATEST_VERSION" | ||
| MAJOR=${VERSION_PARTS[0]:-0} | ||
| MINOR=${VERSION_PARTS[1]:-0} | ||
| PATCH=${VERSION_PARTS[2]:-0} | ||
| PATCH=$((PATCH + 1)) | ||
| VERSION="${MAJOR}.${MINOR}.${PATCH}" | ||
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | ||
| echo "tag=v${VERSION}" >> $GITHUB_OUTPUT | ||
| echo "Next version: ${VERSION}" | ||
|
|
||
| - name: Build docs skills | ||
| run: pnpm run build:docs-skills | ||
|
|
||
| # Compare only name fields in posthog docs entries (not install commands, | ||
| # which are stable but we want to catch additions/removals/renames). | ||
| - name: Check for changes | ||
| id: diff | ||
| env: | ||
| PREV_MENU_URL: ${{ github.server_url }}/${{ github.repository }}/releases/latest/download/docs-skill-menu.json | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is probably fine, but asking these just in case:
|
||
| run: | | ||
| if curl -sf -o /tmp/prev-skill-menu.json "$PREV_MENU_URL" 2>/dev/null; then | ||
| jq '[.categories["posthog-docs"] // [] | .[] | .name] | sort' \ | ||
| dist/skills/docs-skill-menu.json > /tmp/new-names.json | ||
| jq '[.categories["posthog-docs"] // [] | .[] | .name] | sort' \ | ||
| /tmp/prev-skill-menu.json > /tmp/prev-names.json | ||
| if diff -q /tmp/prev-names.json /tmp/new-names.json > /dev/null 2>&1; then | ||
| echo "posthog-docs skills unchanged — skipping release" | ||
| echo "changed=false" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "posthog-docs skills changed" | ||
| diff /tmp/prev-names.json /tmp/new-names.json || true | ||
| echo "changed=true" >> $GITHUB_OUTPUT | ||
| fi | ||
| else | ||
| echo "No previous release found — treating as changed" | ||
| echo "changed=true" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| # dist/ is gitignored; force-add skill-menu.json so there's a committed | ||
| # record of each sync. Tags are pushed AFTER the release succeeds so that | ||
| # "latest" never points at a commit whose ZIPs don't exist yet. | ||
| - name: Commit updated docs-skill-menu.json | ||
| if: steps.diff.outputs.changed == 'true' | ||
| env: | ||
| TAG: ${{ steps.version.outputs.tag }} | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| git add -f dist/skills/docs-skill-menu.json | ||
| git commit -m "chore: sync posthog-docs skills (${TAG})" | ||
| git push | ||
|
|
||
| - name: Zip skill directories and create release | ||
| if: steps.diff.outputs.changed == 'true' | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| TAG: ${{ steps.version.outputs.tag }} | ||
| VERSION: ${{ steps.version.outputs.version }} | ||
| EVENT_NAME: ${{ github.event_name }} | ||
| run: | | ||
| SKILL_COUNT=$(jq '.categories["posthog-docs"] | length' dist/skills/docs-skill-menu.json) | ||
|
|
||
| # Zip each posthog-* skill directory | ||
| cd dist/skills | ||
| for skill_dir in posthog-*/; do | ||
| skill_name="${skill_dir%/}" | ||
| zip -r "${skill_name}.zip" "${skill_dir}" | ||
| echo " zipped ${skill_name}.zip" | ||
| done | ||
| cd ../.. | ||
|
|
||
| # gh release create also creates the version tag on GitHub, pointing at | ||
| # the commit we just pushed above. If this step fails: the commit is | ||
| # already pushed (benign — it only updates docs-skill-menu.json) but | ||
| # no tag or release exists. The "Update latest tag" step is skipped | ||
| # automatically on failure, so "latest" stays valid. The nightly cron | ||
| # will reattempt; since no version tag was pushed, it will compute the | ||
| # same version number and try again cleanly. | ||
| gh release create "${TAG}" \ | ||
| --title "Release ${TAG}" \ | ||
| --notes "Automated sync of PostHog docs skills. | ||
|
|
||
| **Trigger:** ${EVENT_NAME} | ||
| **Version:** ${VERSION} | ||
| **posthog-docs skills:** ${SKILL_COUNT} | ||
| **SHA:** $(git rev-parse HEAD)" \ | ||
| dist/skills/docs-skill-menu.json \ | ||
| dist/skills/posthog-*.zip | ||
|
|
||
| echo "Release ${TAG} created successfully (${SKILL_COUNT} skills)" | ||
|
|
||
| # Only move the floating "latest" tag once the release + ZIPs are confirmed live. | ||
| - name: Update latest tag | ||
| if: steps.diff.outputs.changed == 'true' | ||
| run: | | ||
| git tag -f latest | ||
| git push -f origin latest | ||
|
|
||
| - name: Notify on failure | ||
| if: failure() | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| gh issue create \ | ||
| --repo "${{ github.repository }}" \ | ||
| --title "sync-docs-skills failed ($(date +%Y-%m-%d))" \ | ||
| --body "Workflow run failed: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \ | ||
| || echo "Issue creation failed — check the Actions run directly." | ||
|
|
||
| - name: Summary | ||
| if: always() | ||
| env: | ||
| CHANGED: ${{ steps.diff.outputs.changed }} | ||
| TAG: ${{ steps.version.outputs.tag }} | ||
| VERSION: ${{ steps.version.outputs.version }} | ||
| EVENT_NAME: ${{ github.event_name }} | ||
| run: | | ||
| if [ "${CHANGED}" == "true" ]; then | ||
| SKILL_COUNT=$(jq '.categories["posthog-docs"] | length' dist/skills/docs-skill-menu.json 2>/dev/null || echo "unknown") | ||
| echo "## Sync complete — ${TAG}" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "| Field | Value |" >> $GITHUB_STEP_SUMMARY | ||
| echo "| --- | --- |" >> $GITHUB_STEP_SUMMARY | ||
| echo "| Version | ${VERSION} |" >> $GITHUB_STEP_SUMMARY | ||
| echo "| Trigger | ${EVENT_NAME} |" >> $GITHUB_STEP_SUMMARY | ||
| echo "| posthog-docs skills | ${SKILL_COUNT} |" >> $GITHUB_STEP_SUMMARY | ||
| else | ||
| echo "## No changes — skipped" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "posthog-docs skills unchanged; no release cut." >> $GITHUB_STEP_SUMMARY | ||
| fi | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
YES