diff --git a/.github/workflows/sync-plugin.yml b/.github/workflows/sync-plugin.yml index ce6742d527..b3ca88ca0c 100644 --- a/.github/workflows/sync-plugin.yml +++ b/.github/workflows/sync-plugin.yml @@ -4,8 +4,7 @@ on: push: branches: [main] paths: - - 'skills/**' - - '.claude-plugin/**' + - '.claude-plugin/plugin.json' jobs: sync: @@ -14,9 +13,26 @@ jobs: - name: Checkout CLI repo uses: actions/checkout@v4 with: + fetch-depth: 2 path: cli + - name: Check if version changed + id: version + run: | + cd cli + OLD=$(git show HEAD~1:.claude-plugin/plugin.json 2>/dev/null | jq -r '.version' 2>/dev/null || echo "") + NEW=$(jq -r '.version' .claude-plugin/plugin.json) + if [ "$OLD" = "$NEW" ]; then + echo "Version unchanged ($NEW), skipping sync" + echo "changed=false" >> $GITHUB_OUTPUT + else + echo "Version changed: $OLD → $NEW" + echo "changed=true" >> $GITHUB_OUTPUT + echo "version=$NEW" >> $GITHUB_OUTPUT + fi + - name: Checkout Plugin repo + if: steps.version.outputs.changed == 'true' uses: actions/checkout@v4 with: repository: firecrawl/firecrawl-claude-plugin @@ -24,6 +40,7 @@ jobs: path: plugin - name: Copy files + if: steps.version.outputs.changed == 'true' run: | # Sync skill files rm -rf plugin/skills/firecrawl-cli @@ -33,20 +50,12 @@ jobs: cp cli/.claude-plugin/plugin.json plugin/.claude-plugin/plugin.json cp cli/.claude-plugin/marketplace.json plugin/.claude-plugin/marketplace.json - - name: Bump version - run: | - cd plugin - VERSION=$(jq -r '.version' .claude-plugin/plugin.json) - IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION" - NEW_VERSION="$MAJOR.$MINOR.$((PATCH + 1))" - jq --arg v "$NEW_VERSION" '.version = $v' .claude-plugin/plugin.json > tmp.json - mv tmp.json .claude-plugin/plugin.json - echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV - - name: Create PR + if: steps.version.outputs.changed == 'true' run: | cd plugin - BRANCH="sync/cli-v${{ env.NEW_VERSION }}" + VERSION="${{ steps.version.outputs.version }}" + BRANCH="sync/cli-v${VERSION}" git checkout -b "$BRANCH" git add -A if git diff --cached --quiet; then @@ -55,12 +64,12 @@ jobs: fi git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - git commit -m "Sync from firecrawl/cli — v${{ env.NEW_VERSION }}" + git commit -m "Sync from firecrawl/cli — v${VERSION}" git push origin "$BRANCH" gh pr create \ --repo firecrawl/firecrawl-claude-plugin \ - --title "Sync CLI changes → v${{ env.NEW_VERSION }}" \ - --body "Automated sync from [firecrawl/cli](https://github.com/firecrawl/cli) main branch." \ + --title "Sync CLI changes → v${VERSION}" \ + --body "Automated sync from [firecrawl/cli](https://github.com/firecrawl/cli) main branch (v${VERSION})." \ --base main \ --head "$BRANCH" env: