|
| 1 | +name: Generate TypeScript Types |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + paths: |
| 8 | + - 'lib/clusters/**/*.js' |
| 9 | + - 'scripts/generate-types.js' |
| 10 | + |
| 11 | +jobs: |
| 12 | + generate-types: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + |
| 15 | + permissions: |
| 16 | + contents: write |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Checkout repository |
| 20 | + uses: actions/checkout@v4 |
| 21 | + with: |
| 22 | + ref: develop |
| 23 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 24 | + |
| 25 | + - name: Setup Node.js |
| 26 | + uses: actions/setup-node@v4 |
| 27 | + with: |
| 28 | + node-version: '20' |
| 29 | + cache: 'npm' |
| 30 | + |
| 31 | + - name: Install dependencies |
| 32 | + run: npm ci |
| 33 | + |
| 34 | + - name: Generate TypeScript types |
| 35 | + run: npm run generate-types |
| 36 | + |
| 37 | + - name: Validate TypeScript types compile |
| 38 | + run: npx tsc --noEmit index.d.ts |
| 39 | + |
| 40 | + - name: Check for changes |
| 41 | + id: check-changes |
| 42 | + run: | |
| 43 | + if git diff --quiet index.d.ts; then |
| 44 | + echo "changed=false" >> $GITHUB_OUTPUT |
| 45 | + echo "No changes to index.d.ts" |
| 46 | + else |
| 47 | + echo "changed=true" >> $GITHUB_OUTPUT |
| 48 | + echo "index.d.ts has been updated" |
| 49 | + git diff --stat index.d.ts |
| 50 | + fi |
| 51 | +
|
| 52 | + - name: Commit and push changes |
| 53 | + if: steps.check-changes.outputs.changed == 'true' |
| 54 | + run: | |
| 55 | + git config user.name "github-actions[bot]" |
| 56 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 57 | + git add index.d.ts |
| 58 | + git commit -m "chore(types): auto-generate TypeScript definitions |
| 59 | +
|
| 60 | + Updated by GitHub Actions after cluster changes. |
| 61 | +
|
| 62 | + [skip ci]" |
| 63 | + git push origin develop |
0 commit comments