Port Bot - aiCore Changes #20
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
| name: Port Bot - aiCore Changes | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| on: | |
| schedule: | |
| # Run every 6 hours to check for changes | |
| - cron: '0 */6 * * *' | |
| workflow_dispatch: | |
| inputs: | |
| source_ref: | |
| description: 'Source repository ref (branch/tag/commit)' | |
| required: false | |
| default: 'main' | |
| jobs: | |
| check-and-port: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout current repository | |
| uses: actions/checkout@v5 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| fetch-depth: 1 | |
| - name: Get last ported commit | |
| id: last-port | |
| run: | | |
| # Try to get the last ported commit from tracking file | |
| if [ -f .github/port-bot-state ]; then | |
| LAST_COMMIT=$(cat .github/port-bot-state) | |
| echo "π Using tracked commit: $LAST_COMMIT" | |
| else | |
| # First run - use a reasonable starting point (30 days ago) | |
| LAST_COMMIT="HEAD~100" # Fallback: last 100 commits | |
| echo "βΉοΈ No state file found, using fallback" | |
| fi | |
| echo "last_commit=$LAST_COMMIT" >> $GITHUB_OUTPUT | |
| echo "last_commit_display=${LAST_COMMIT:0:7}" >> $GITHUB_OUTPUT | |
| - name: Create Copilot Agent task | |
| env: | |
| COPILOT_TOKEN: ${{ secrets.COPILOT_TOKEN }} | |
| run: | | |
| # Authenticate gh CLI (must clear GITHUB_TOKEN first) | |
| echo "π Authenticating gh CLI..." | |
| # Use env -u to run gh auth login without GITHUB_TOKEN | |
| echo "$COPILOT_TOKEN" | env -u GITHUB_TOKEN gh auth login --with-token | |
| # Verify authentication | |
| env -u GITHUB_TOKEN gh auth status || { | |
| echo "β Authentication failed!" | |
| exit 1 | |
| } | |
| echo "β Authentication successful" | |
| # Let Copilot Agent handle everything (also clear GITHUB_TOKEN) | |
| env -u GITHUB_TOKEN gh agent-task create \ | |
| --base main \ | |
| --repo ${{ github.repository }} \ | |
| --follow \ | |
| "Port changes from CherryHQ/cherry-studio repository's \`src/renderer/src/aiCore\` directory to this repo's \`src/aiCore\` directory. | |
| **Source repository**: https://github.com/CherryHQ/cherry-studio | |
| **Last ported commit**: ${{ steps.last-port.outputs.last_commit_display || 'first time' }} | |
| **Target**: Port all new changes to \`src/aiCore/\` | |
| **This is a React Native/Expo mobile app** porting from an Electron desktop app. | |
| **Required transformations**: | |
| 1. Path mapping: \`src/renderer/src/aiCore\` β \`src/aiCore\` | |
| 2. Import rewrites: | |
| - \`@renderer/**\` β \`@/**\` | |
| - \`@logger\` β \`@/services/LoggerService\` | |
| 3. Electron β React Native adaptations: | |
| - Replace Node.js APIs (\`fs\`, \`path\`) with \`expo-file-system\` | |
| - Remove Electron IPC, use React Native bridge if needed | |
| - Make all file operations async | |
| - Use RN-compatible packages only | |
| 4. Fix ESLint differences (this repo has stricter rules) | |
| **Steps**: | |
| 1. Fetch latest changes from https://github.com/CherryHQ/cherry-studio | |
| 2. Generate diff for \`src/renderer/src/aiCore\` since last port | |
| 3. Apply transformations above using bash/sed/find | |
| 4. Port changes to \`src/aiCore/\` | |
| 5. Run \`yarn format && yarn lint\` to fix style | |
| 6. Update \`.github/port-bot-state\` with the latest upstream commit hash | |
| 7. Create PR with summary of changes and upstream commits | |
| **Important**: | |
| - DO NOT modify \`.github/workflows/\` | |
| - Focus ONLY on \`src/aiCore/\` directory | |
| - Ensure all imports resolve correctly | |
| - Test that no Node.js-only APIs remain" | |
| echo "" | |
| echo "β Copilot Agent task created" | |
| echo "π€ Agent will handle: fetch, diff, transform, port, lint, PR" | |
| echo "π Monitor: https://github.com/${{ github.repository }}/pulls" | |
| - name: Summary | |
| if: always() | |
| run: | | |
| echo "===================================" | |
| echo "π€ Port Bot - Copilot Agent Mode" | |
| echo "===================================" | |
| echo "" | |
| echo "β Task created successfully" | |
| echo "" | |
| echo "π What happens next:" | |
| echo " 1. Copilot Agent fetches upstream changes" | |
| echo " 2. Generates and applies transformed patch" | |
| echo " 3. Runs lint and format" | |
| echo " 4. Creates PR automatically" | |
| echo "" | |
| echo "π Track progress at:" | |
| echo " https://github.com/${{ github.repository }}/pulls" | |
| echo "" | |
| echo "===================================" |