-
Notifications
You must be signed in to change notification settings - Fork 19
106 lines (90 loc) · 4.17 KB
/
sync-skill-to-plugins.yml
File metadata and controls
106 lines (90 loc) · 4.17 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
# ABOUTME: GitHub Actions workflow that syncs skill contents to the cursor and codex plugin repos.
# ABOUTME: Triggers when a new release is created (by the package-skill workflow) or manually.
# ABOUTME: Creates or updates a PR in each target repo rather than pushing directly to main.
# ABOUTME: Uses a GitHub App for cross-repo authentication. Required secrets:
# ABOUTME: SKILL_T_DEV_APP_ID — the GitHub App's ID
# ABOUTME: SKILL_T_DEV_KEY — the GitHub App's private key
# ABOUTME: The app must be installed on all three repos with Contents (write) and
# ABOUTME: Pull Requests (write) permissions.
name: Sync Skill to Plugin Repos
on:
release:
types: [published]
workflow_dispatch:
permissions:
contents: read
jobs:
sync:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- repo: temporalio/cursor-temporal-plugin
target_path: skills/temporal-developer
- repo: temporalio/codex-temporal-plugin
target_path: plugins/temporal-developer/skills/temporal-developer
- repo: temporalio/claude-temporal-plugin
target_path: skills/temporal-developer
steps:
- name: Generate token from GitHub App
id: app-token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.SKILL_T_DEV_APP_ID }}
private-key: ${{ secrets.SKILL_T_DEV_KEY }}
owner: ${{ github.repository_owner }}
- name: Checkout source
uses: actions/checkout@v4
- name: Checkout target repo
uses: actions/checkout@v4
with:
repository: ${{ matrix.repo }}
token: ${{ steps.app-token.outputs.token }}
path: target-repo
- name: Sync skill contents
working-directory: target-repo
run: |
BRANCH="sync/temporal-developer-skill"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Create or reset the sync branch based on current main.
# -B ensures the branch always starts from main's tip, even if a
# stale remote branch exists from a previously merged PR.
git checkout -B "$BRANCH" origin/main
# Remove old contents and copy current
rm -rf "${{ matrix.target_path }}/SKILL.md" \
"${{ matrix.target_path }}/references"
cp ../SKILL.md "${{ matrix.target_path }}/"
cp -r ../references "${{ matrix.target_path }}/"
# Check for changes against main
git add "${{ matrix.target_path }}"
if git diff --cached --quiet; then
echo "no_changes=true" >> "$GITHUB_ENV"
echo "No changes to sync"
else
echo "no_changes=false" >> "$GITHUB_ENV"
version="${{ github.event.release.tag_name || 'manual' }}"
git commit -m "sync temporal-developer skill ${version} from source repo"
git push --force origin "$BRANCH"
fi
- name: Create or update PR
if: env.no_changes == 'false'
working-directory: target-repo
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
BRANCH="sync/temporal-developer-skill"
version="${{ github.event.release.tag_name || 'manual' }}"
# Check if a PR already exists from this branch
existing_pr=$(gh pr list --head "$BRANCH" --state open --json number --jq '.[0].number')
if [ -n "$existing_pr" ]; then
echo "PR #${existing_pr} already exists — updated by the force-push"
gh pr comment "$existing_pr" --body "Updated to ${version} from [skill-temporal-developer](https://github.com/${{ github.repository }})."
else
body="Automated sync of the temporal-developer skill ${version} from [skill-temporal-developer](https://github.com/${{ github.repository }}).
This PR was created automatically by the [sync workflow](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})."
gh pr create \
--title "Sync temporal-developer skill ${version}" \
--body "$body"
fi