Sync Skills Directory #32
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: Sync Skills Directory | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| on: | |
| schedule: | |
| - cron: '0 0 * * *' # Runs daily at midnight UTC | |
| workflow_dispatch: # Allows manual triggering | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 1. Checkout Flutter Skills (Destination) | |
| - name: Checkout Flutter Skills (Destination) | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| token: ${{ secrets.SYNC_PAT || github.token }} # Falls back to default if SYNC_PAT is undefined | |
| persist-credentials: false | |
| path: dest_repo | |
| # 2. Checkout Dart Skills (Source) | |
| - name: Checkout Dart Skills (Source) | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| repository: dart-lang/skills | |
| fetch-depth: 50 | |
| persist-credentials: false | |
| path: src_repo | |
| # 3. Setup Dart Environment | |
| - name: Setup Dart Environment | |
| uses: dart-lang/setup-dart@65eb853c7ba17dde3be364c3d2858773e7144260 # v1.7.2 | |
| with: | |
| sdk: stable | |
| # 4. Sync files and copy | |
| - name: Execute Dart Sync Engine | |
| id: sync_engine | |
| run: | | |
| cd dest_repo | |
| # Initialize exit code and run the sync script | |
| EXIT_CODE=0 | |
| dart run tool/sync_skills.dart ../src_repo skills || EXIT_CODE=$? | |
| # Map exit codes to GITHUB_OUTPUT | |
| if [ $EXIT_CODE -eq 0 ]; then | |
| echo "changes_detected=true" >> $GITHUB_OUTPUT | |
| echo "✅ Changes detected. Preparing to create a PR." | |
| elif [ $EXIT_CODE -eq 10 ]; then | |
| echo "changes_detected=false" >> $GITHUB_OUTPUT | |
| echo "✅ Dart script signaled NO changes were found. Stopping workflow." | |
| else | |
| echo "❌ Dart script failed with error code $EXIT_CODE" | |
| exit $EXIT_CODE | |
| fi | |
| # 5. Configure Git Credentials under allowlisted Robot Bot | |
| - name: Configure Git Credentials | |
| run: | | |
| git config --global user.name "flutter-skills-sync-bot" | |
| git config --global user.email "flutter-agent-sync-bot@google.com" | |
| env: | |
| GH_TOKEN: ${{ secrets.SYNC_PAT || github.token }} | |
| # 6. Create Pull Request using custom PAT credentials | |
| - name: Create Pull Request | |
| if: steps.sync_engine.outputs.changes_detected == 'true' | |
| uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1 (Pinned to official hash) | |
| with: | |
| token: ${{ secrets.SYNC_PAT || github.token }} | |
| path: dest_repo | |
| branch: automation/sync-dart-skills | |
| title: "🤖 chore: sync skills directory from dart-lang/skills" | |
| commit-message: "chore: auto-sync skills directory from dart-lang/skills" | |
| committer: flutter-skills-sync-bot <flutter-agent-sync-bot@google.com> | |
| author: flutter-skills-sync-bot <flutter-agent-sync-bot@google.com> |