|
| 1 | +name: Sync to Claude Scientific Skills |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + |
| 7 | +jobs: |
| 8 | + sync: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + permissions: |
| 11 | + contents: write |
| 12 | + steps: |
| 13 | + - name: Checkout this repository |
| 14 | + uses: actions/checkout@v4 |
| 15 | + with: |
| 16 | + path: idc-skill |
| 17 | + |
| 18 | + - name: Extract version from release tag |
| 19 | + id: version |
| 20 | + run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT |
| 21 | + |
| 22 | + - name: Clone upstream claude-scientific-skills |
| 23 | + run: | |
| 24 | + git clone https://github.com/K-Dense-AI/claude-scientific-skills.git scientific-skills |
| 25 | +
|
| 26 | + - name: Update skill files |
| 27 | + run: | |
| 28 | + # Target directory in the scientific-skills repo |
| 29 | + TARGET_DIR="scientific-skills/scientific-skills/imaging-data-commons" |
| 30 | +
|
| 31 | + # Remove existing files |
| 32 | + rm -rf "$TARGET_DIR" |
| 33 | + mkdir -p "$TARGET_DIR" |
| 34 | +
|
| 35 | + # Copy SKILL.md and references directory |
| 36 | + cp idc-skill/SKILL.md "$TARGET_DIR/" |
| 37 | + cp -r idc-skill/references "$TARGET_DIR/" |
| 38 | +
|
| 39 | + echo "Updated files in $TARGET_DIR:" |
| 40 | + ls -la "$TARGET_DIR" |
| 41 | +
|
| 42 | + - name: Create branch with updated skill |
| 43 | + id: create-branch |
| 44 | + run: | |
| 45 | + cd scientific-skills |
| 46 | +
|
| 47 | + BRANCH_NAME="update-idc-skill-to-v${{ steps.version.outputs.version }}" |
| 48 | +
|
| 49 | + git config user.name "github-actions[bot]" |
| 50 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 51 | +
|
| 52 | + git checkout -b "$BRANCH_NAME" |
| 53 | + git add scientific-skills/imaging-data-commons/ |
| 54 | +
|
| 55 | + # Check if there are changes to commit |
| 56 | + if git diff --staged --quiet; then |
| 57 | + echo "No changes to commit" |
| 58 | + echo "has_changes=false" >> $GITHUB_OUTPUT |
| 59 | + exit 0 |
| 60 | + fi |
| 61 | +
|
| 62 | + git commit -m "Update imaging-data-commons skill to v${{ steps.version.outputs.version }}" |
| 63 | + echo "has_changes=true" >> $GITHUB_OUTPUT |
| 64 | + echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT |
| 65 | +
|
| 66 | + - name: Push branch to idc-claude-skill repo |
| 67 | + if: steps.create-branch.outputs.has_changes == 'true' |
| 68 | + run: | |
| 69 | + cd scientific-skills |
| 70 | +
|
| 71 | + BRANCH_NAME="${{ steps.create-branch.outputs.branch_name }}" |
| 72 | +
|
| 73 | + # Add this repo as a remote and push the branch there |
| 74 | + git remote add idc-repo https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git |
| 75 | + git push idc-repo "$BRANCH_NAME" |
| 76 | +
|
| 77 | + echo "::notice::Pushed branch '$BRANCH_NAME' to ${{ github.repository }}" |
| 78 | + echo "::notice::Create PR at: https://github.com/K-Dense-AI/claude-scientific-skills/compare/main...${{ github.repository_owner }}:claude-scientific-skills:$BRANCH_NAME" |
0 commit comments