|  | 
| 6 | 6 |       - main | 
| 7 | 7 |       - 8.x | 
| 8 | 8 |       - '[0-9]+.[0-9]+' | 
|  | 9 | +  push: | 
|  | 10 | +    branches: | 
|  | 11 | +      - main | 
|  | 12 | +      - '[0-9]+.[0-9]+' | 
|  | 13 | + | 
|  | 14 | +permissions: | 
|  | 15 | +  pull-requests: write    # To create/update PR comments | 
| 9 | 16 | 
 | 
| 10 | 17 | jobs: | 
| 11 |  | -  validate-pr: | 
|  | 18 | +  validate-apis: | 
| 12 | 19 |     name: build | 
| 13 | 20 |     runs-on: ubuntu-latest | 
| 14 | 21 | 
 | 
| 15 | 22 |     steps: | 
| 16 | 23 |       - name: Check pull request was opened from branch | 
| 17 |  | -        if: github.event.pull_request.head.repo.full_name != 'elastic/elasticsearch-specification' | 
|  | 24 | +        if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != 'elastic/elasticsearch-specification' | 
| 18 | 25 |         run: echo "Validation is not supported from forks"; exit 1 | 
| 19 | 26 | 
 | 
| 20 | 27 |       - uses: actions/checkout@v4 | 
| 21 | 28 |         with: | 
| 22 | 29 |           path: ./elasticsearch-specification | 
|  | 30 | +          persist-credentials: false | 
| 23 | 31 | 
 | 
| 24 | 32 |       - uses: actions/checkout@v4 | 
| 25 | 33 |         with: | 
| 26 | 34 |           repository: elastic/clients-flight-recorder | 
| 27 | 35 |           path: ./clients-flight-recorder | 
| 28 | 36 |           token: ${{ secrets.PAT }} | 
| 29 | 37 |           ref: ${{ github.base_ref }} | 
|  | 38 | +          persist-credentials: false | 
| 30 | 39 | 
 | 
| 31 | 40 |       - name: Use Node.js 22 | 
| 32 | 41 |         uses: actions/setup-node@v4 | 
| 33 | 42 |         with: | 
| 34 | 43 |           node-version: 22 | 
| 35 | 44 | 
 | 
|  | 45 | +      - name: Cache JSON report | 
|  | 46 | +        id: cache-json-report | 
|  | 47 | +        uses: actions/cache@v4 | 
|  | 48 | +        with: | 
|  | 49 | +          path: ./clients-flight-recorder/recordings/types-validation/types-validation.json | 
|  | 50 | +          key: types-validation-json-${{ github.event_name == 'pull_request' && format('{0}-{1}', github.head_ref, github.event.pull_request.base.sha) || format('{0}-{1}', github.ref_name, github.sha) }} | 
|  | 51 | +          restore-keys: | | 
|  | 52 | +            types-validation-json-${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }}- | 
|  | 53 | +
 | 
| 36 | 54 |       - name: Install deps 1/2 | 
| 37 | 55 |         working-directory: ./clients-flight-recorder | 
| 38 | 56 |         run: | | 
| @@ -64,12 +82,21 @@ jobs: | 
| 64 | 82 |         env: | 
| 65 | 83 |           GCS_CREDENTIALS: ${{ secrets.GCS_CREDENTIALS }} | 
| 66 | 84 | 
 | 
| 67 |  | -      - name: Run validation | 
|  | 85 | +      - name: Run validation (Push) | 
|  | 86 | +        if: github.event_name == 'push' | 
|  | 87 | +        working-directory: ./clients-flight-recorder/scripts/types-validator | 
|  | 88 | +        env: | 
|  | 89 | +          BRANCH: ${{ github.ref_name }} | 
|  | 90 | +        run: node index.js --generate-report --ci --branch $BRANCH | 
|  | 91 | + | 
|  | 92 | +      - name: Run validation (PR) | 
|  | 93 | +        if: github.event_name == 'pull_request' | 
| 68 | 94 |         id: validation | 
| 69 | 95 |         working-directory: ./elasticsearch-specification | 
| 70 | 96 |         run: node .github/validate-pr --token ${{ secrets.GITHUB_TOKEN }} | 
| 71 | 97 | 
 | 
| 72 | 98 |       - name: Find existing comment | 
|  | 99 | +        if: github.event_name == 'pull_request' | 
| 73 | 100 |         uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3.1.0 | 
| 74 | 101 |         id: find-comment | 
| 75 | 102 |         with: | 
|  | 
| 78 | 105 |           body-includes: 'Following you can find the validation changes' | 
| 79 | 106 | 
 | 
| 80 | 107 |       - name: Create or update comment | 
|  | 108 | +        if: github.event_name == 'pull_request' | 
| 81 | 109 |         uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0 | 
| 82 | 110 |         with: | 
| 83 | 111 |           token: ${{ secrets.GITHUB_TOKEN }} | 
|  | 
0 commit comments