|
| 1 | +name: Sync Skills |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + paths: ['skills/**'] |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: sync-skills |
| 11 | + cancel-in-progress: false |
| 12 | + |
| 13 | +jobs: |
| 14 | + sync: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - name: Checkout source repo |
| 18 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd |
| 19 | + with: |
| 20 | + path: source |
| 21 | + |
| 22 | + - name: Checkout resend-skills |
| 23 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd |
| 24 | + with: |
| 25 | + repository: resend/resend-skills |
| 26 | + token: ${{ secrets.SYNC_SKILLS_TOKEN }} |
| 27 | + path: target |
| 28 | + |
| 29 | + - name: Compare skills |
| 30 | + id: diff |
| 31 | + run: | |
| 32 | + changed=false |
| 33 | + for skill_dir in source/skills/*/; do |
| 34 | + skill_name=$(basename "$skill_dir") |
| 35 | + target_dir="target/skills/$skill_name" |
| 36 | +
|
| 37 | + if [ ! -d "$target_dir" ]; then |
| 38 | + echo "New skill: $skill_name" |
| 39 | + changed=true |
| 40 | + continue |
| 41 | + fi |
| 42 | +
|
| 43 | + # Compare only spec-compliant files: SKILL.md, references/, scripts/, assets/ |
| 44 | + for item in SKILL.md references scripts assets; do |
| 45 | + src="$skill_dir/$item" |
| 46 | + dst="$target_dir/$item" |
| 47 | + if [ -e "$src" ] && ! diff -rq "$src" "$dst" > /dev/null 2>&1; then |
| 48 | + echo "Changed: $skill_name/$item" |
| 49 | + changed=true |
| 50 | + fi |
| 51 | + done |
| 52 | + done |
| 53 | +
|
| 54 | + echo "changed=$changed" >> "$GITHUB_OUTPUT" |
| 55 | +
|
| 56 | + - name: Copy skills and open PR |
| 57 | + if: steps.diff.outputs.changed == 'true' |
| 58 | + env: |
| 59 | + GH_TOKEN: ${{ secrets.SYNC_SKILLS_TOKEN }} |
| 60 | + run: | |
| 61 | + cd target |
| 62 | +
|
| 63 | + git config user.name "github-actions[bot]" |
| 64 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 65 | + git checkout -b sync/resend-cli-${{ github.sha }} |
| 66 | +
|
| 67 | + for skill_dir in ../source/skills/*/; do |
| 68 | + skill_name=$(basename "$skill_dir") |
| 69 | + rm -rf "skills/$skill_name" |
| 70 | + mkdir -p "skills/$skill_name" |
| 71 | +
|
| 72 | + # Copy only spec-compliant files |
| 73 | + cp "$skill_dir/SKILL.md" "skills/$skill_name/" |
| 74 | + for dir in references scripts assets; do |
| 75 | + if [ -d "$skill_dir/$dir" ]; then |
| 76 | + cp -r "$skill_dir/$dir" "skills/$skill_name/" |
| 77 | + fi |
| 78 | + done |
| 79 | + done |
| 80 | +
|
| 81 | + git add skills/ |
| 82 | + git commit -m "sync: resend-cli skills from ${GITHUB_SHA::7}" |
| 83 | + git push origin sync/resend-cli-${{ github.sha }} |
| 84 | +
|
| 85 | + gh pr create \ |
| 86 | + --repo resend/resend-skills \ |
| 87 | + --title "Sync resend-cli skills" \ |
| 88 | + --body "Automated sync from [resend/resend-cli@\`${GITHUB_SHA::7}\`](https://github.com/resend/resend-cli/commit/${{ github.sha }})." |
0 commit comments