|
| 1 | +name: JavaScript Type Checking |
| 2 | + |
| 3 | +on: |
| 4 | + # JavaScript type checking was introduced in 7.0.0. |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - trunk |
| 8 | + - '[7-9].[0-9]' |
| 9 | + tags: |
| 10 | + - '[7-9].[0-9]' |
| 11 | + - '[7-9]+.[0-9].[0-9]+' |
| 12 | + pull_request: |
| 13 | + branches: |
| 14 | + - trunk |
| 15 | + - '[7-9].[0-9]' |
| 16 | + paths: |
| 17 | + # This workflow only scans JavaScript files. |
| 18 | + - '**.js' |
| 19 | + - '**.ts' |
| 20 | + - '**.tsx' |
| 21 | + # These files configure npm. Changes could affect the outcome. |
| 22 | + - 'package*.json' |
| 23 | + - '.nvmrc' |
| 24 | + - '.npmrc' |
| 25 | + # This file configures TypeScript. Changes could affect the outcome. |
| 26 | + - 'tsconfig.json' |
| 27 | + # This directory contains TypeScript definitions. Changes could affect the outcome. |
| 28 | + - 'typings/**' |
| 29 | + # Confirm any changes to relevant workflow files. |
| 30 | + - '.github/workflows/javascript-type-checking.yml' |
| 31 | + - '.github/workflows/reusable-javascript-type-checking-v1.yml' |
| 32 | + workflow_dispatch: |
| 33 | + |
| 34 | +# Cancels all previous workflow runs for pull requests that have not completed. |
| 35 | +concurrency: |
| 36 | + # The concurrency group contains the workflow name and the branch name for pull requests |
| 37 | + # or the commit hash for any other events. |
| 38 | + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} |
| 39 | + cancel-in-progress: true |
| 40 | + |
| 41 | +# Disable permissions for all available scopes by default. |
| 42 | +# Any needed permissions should be configured at the job level. |
| 43 | +permissions: {} |
| 44 | + |
| 45 | +jobs: |
| 46 | + # Runs JavaScript type checking. |
| 47 | + typecheck: |
| 48 | + name: JavaScript type checking |
| 49 | + uses: ./.github/workflows/reusable-javascript-type-checking-v1.yml |
| 50 | + permissions: |
| 51 | + contents: read |
| 52 | + if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} |
| 53 | + |
| 54 | + slack-notifications: |
| 55 | + name: Slack Notifications |
| 56 | + uses: ./.github/workflows/slack-notifications.yml |
| 57 | + permissions: |
| 58 | + actions: read |
| 59 | + contents: read |
| 60 | + needs: [ typecheck ] |
| 61 | + if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }} |
| 62 | + with: |
| 63 | + calling_status: ${{ contains( needs.*.result, 'cancelled' ) && 'cancelled' || contains( needs.*.result, 'failure' ) && 'failure' || 'success' }} |
| 64 | + secrets: |
| 65 | + SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }} |
| 66 | + SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }} |
| 67 | + SLACK_GHA_FIXED_WEBHOOK: ${{ secrets.SLACK_GHA_FIXED_WEBHOOK }} |
| 68 | + SLACK_GHA_FAILURE_WEBHOOK: ${{ secrets.SLACK_GHA_FAILURE_WEBHOOK }} |
| 69 | + |
| 70 | + failed-workflow: |
| 71 | + name: Failed workflow tasks |
| 72 | + runs-on: ubuntu-24.04 |
| 73 | + permissions: |
| 74 | + actions: write |
| 75 | + needs: [ slack-notifications ] |
| 76 | + if: | |
| 77 | + always() && |
| 78 | + github.repository == 'WordPress/wordpress-develop' && |
| 79 | + github.event_name != 'pull_request' && |
| 80 | + github.run_attempt < 2 && |
| 81 | + ( |
| 82 | + contains( needs.*.result, 'cancelled' ) || |
| 83 | + contains( needs.*.result, 'failure' ) |
| 84 | + ) |
| 85 | +
|
| 86 | + steps: |
| 87 | + - name: Dispatch workflow run |
| 88 | + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 |
| 89 | + with: |
| 90 | + retries: 2 |
| 91 | + retry-exempt-status-codes: 418 |
| 92 | + script: | |
| 93 | + github.rest.actions.createWorkflowDispatch({ |
| 94 | + owner: context.repo.owner, |
| 95 | + repo: context.repo.repo, |
| 96 | + workflow_id: 'failed-workflow.yml', |
| 97 | + ref: 'trunk', |
| 98 | + inputs: { |
| 99 | + run_id: `${context.runId}`, |
| 100 | + } |
| 101 | + }); |
0 commit comments