Auto Generate Types #41375
This file contains 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: Auto Generate Types | |
on: | |
schedule: | |
- cron: '30 * * * *' | |
push: | |
branches: [master] | |
repository_dispatch: | |
types: [auto-generate-types] | |
workflow_dispatch: # for manual testing | |
jobs: | |
generate: | |
runs-on: ubuntu-latest | |
steps: | |
# setup | |
- uses: actions/checkout@v4 | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.nvmrc' | |
cache: 'npm' | |
- name: Install dependencies | |
run: npm ci | |
# we used to download `types` branch here, but looks like we don't need that anymore, and can skip linting old types | |
# generate and lint types | |
- name: Generate types | |
id: generate | |
run: npm start -- --new-revisions-only --cache-discovery-json ${{ runner.temp }} | |
- name: Lint types | |
id: lint | |
run: npm run lint | |
env: | |
GAPI_MAX_PARALLEL: 3 | |
- name: debug1 | |
if: always() | |
run: echo ${{ steps.generate.outputs.FAILED_TYPE }} && echo ${{join(steps.generate.outputs.*, '\n')}} | |
- name: debug2 | |
if: always() | |
run: echo ${{ steps.lint.outputs.FAILED_TYPE }} && echo ${{join(steps.lint.outputs.*, '\n')}} | |
- name: debug3 | |
if: always() | |
run: echo ${{join(steps.*.outputs.*, '\n')}} | |
# upload failed type for investigation | |
- name: Copy discovery service response if failed to generate | |
if: failure() && steps.generate.outputs.FAILED_TYPE != '' | |
run: cp ${{ runner.temp }}/${{ steps.generate.outputs.FAILED_TYPE }}.json types/${{ steps.generate.outputs.FAILED_TYPE }} | |
- name: Copy discovery service response if failed to lint | |
if: failure() && steps.lint.outputs.FAILED_TYPE != '' | |
run: cp ${{ runner.temp }}/${{ steps.lint.outputs.FAILED_TYPE }}.json types/${{ steps.lint.outputs.FAILED_TYPE }} | |
- name: Upload type that failed to generate | |
uses: actions/upload-artifact@v4 | |
if: failure() && steps.generate.outputs.FAILED_TYPE != '' | |
with: | |
name: ${{ steps.generate.outputs.FAILED_TYPE }} | |
path: types/${{ steps.generate.outputs.FAILED_TYPE }} | |
- name: Upload type that failed to lint | |
uses: actions/upload-artifact@v4 | |
if: failure() && steps.lint.outputs.FAILED_TYPE != '' | |
with: | |
name: ${{ steps.lint.outputs.FAILED_TYPE }} | |
path: types/${{ steps.lint.outputs.FAILED_TYPE }} | |
# upload types on success | |
- name: Deploy | |
uses: peaceiris/actions-gh-pages@v4 # cspell:words peaceiris | |
with: | |
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }} | |
publish_branch: types | |
publish_dir: ./types | |
allow_empty_commit: false |