| 1 | name: Nightly AI Codegen |
| 2 | |
| 3 | on: |
| 4 | schedule: |
| 5 | - cron: "0 0 * * *" # Midnight UTC daily |
| 6 | workflow_dispatch: |
| 7 | |
| 8 | concurrency: |
| 9 | group: ${{ github.workflow }}-${{ github.ref }} |
| 10 | cancel-in-progress: true |
| 11 | |
| 12 | permissions: {} |
| 13 | |
| 14 | jobs: |
| 15 | codegen: |
| 16 | name: AI Codegen |
| 17 | if: github.repository_owner == 'Effect-Ts' |
| 18 | runs-on: namespace-profile-linux-small |
| 19 | permissions: |
| 20 | contents: write |
| 21 | pull-requests: write |
| 22 | timeout-minutes: 15 |
| 23 | steps: |
| 24 | - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 |
| 25 | |
| 26 | - name: Install dependencies |
| 27 | uses: ./.github/actions/setup |
| 28 | |
| 29 | - name: Run AI Codegen |
| 30 | run: node packages/tools/ai-codegen/src/bin.ts generate |
| 31 | |
| 32 | - name: Check for changes |
| 33 | id: changes |
| 34 | run: | |
| 35 | # Only consider changes in packages/ai/ |
| 36 | providers=$(git diff --name-only | grep "^packages/ai/" | cut -d'/' -f3 | sort -u | sed 's/^/- /' || true) |
| 37 | if [ -z "$providers" ]; then |
| 38 | echo "has_changes=false" >> $GITHUB_OUTPUT |
| 39 | else |
| 40 | echo "has_changes=true" >> $GITHUB_OUTPUT |
| 41 | { |
| 42 | echo "updated_providers<<EOF" |
| 43 | echo "$providers" |
| 44 | echo "EOF" |
| 45 | } >> $GITHUB_OUTPUT |
| 46 | fi |
| 47 | |
| 48 | - name: Create Pull Request |
| 49 | if: steps.changes.outputs.has_changes == 'true' |
| 50 | uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8 |
| 51 | with: |
| 52 | token: ${{ secrets.GITHUB_TOKEN }} |
| 53 | branch: chore/ai-codegen-update |
| 54 | delete-branch: true |
| 55 | title: "chore: update AI codegen generated files" |
| 56 | body: | |
| 57 | Automated update of AI provider generated code. |
| 58 | |
| 59 | ## Updated Providers |
| 60 | |
| 61 | ${{ steps.changes.outputs.updated_providers }} |
| 62 | |
| 63 | --- |
| 64 | |
| 65 | *This PR was automatically generated by the nightly codegen workflow.* |
| 66 | commit-message: "chore: regenerate AI provider code" |
| 67 | labels: automated |