Fix GitHub Actions warning (#5494) (#5538) #359
This file contains hidden or 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: Validate APIs | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| - '[0-9]+.[0-9]+' | |
| push: | |
| branches: | |
| - main | |
| - '[0-9]+.[0-9]+' | |
| permissions: | |
| pull-requests: write # To create/update PR comments | |
| jobs: | |
| validate-apis: | |
| name: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check pull request was opened from branch | |
| if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != 'elastic/elasticsearch-specification' | |
| run: echo "Validation is not supported from forks"; exit 1 | |
| - uses: actions/checkout@v5 | |
| with: | |
| path: ./elasticsearch-specification | |
| persist-credentials: false | |
| - uses: actions/checkout@v5 | |
| with: | |
| repository: elastic/clients-flight-recorder | |
| path: ./clients-flight-recorder | |
| token: ${{ secrets.PAT }} | |
| ref: ${{ github.base_ref }} | |
| persist-credentials: false | |
| - name: Use Node.js 22 | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: 22 | |
| - name: Restore JSON report | |
| if: github.event_name == 'pull_request' | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: ./clients-flight-recorder/recordings/types-validation/types-validation.json | |
| key: types-validation-json-${{ format('{0}-{1}', github.base_ref, github.event.pull_request.base.sha) }} | |
| restore-keys: | | |
| types-validation-json-${{ github.base_ref }}- | |
| - name: Install deps 1/2 | |
| working-directory: ./clients-flight-recorder | |
| run: | | |
| npm install --prefix scripts/clone-elasticsearch | |
| npm install --prefix scripts/upload-recording | |
| npm install --prefix scripts/types-validator | |
| - name: Install deps 2/2 | |
| working-directory: ./elasticsearch-specification | |
| run: | | |
| npm install --prefix .github/validate-pr | |
| make setup | |
| - name: Generate specification and check generated types | |
| working-directory: ./elasticsearch-specification | |
| run: | | |
| make contrib | |
| - name: Download artifacts | |
| working-directory: ./clients-flight-recorder | |
| run: | | |
| if [[ -n "${GITHUB_BASE_REF:-}" ]]; then | |
| branch=$GITHUB_BASE_REF | |
| else | |
| branch=$GITHUB_REF_NAME | |
| fi | |
| echo "Using branch: $branch" | |
| node scripts/upload-recording/download.js --branch $branch --git | |
| node scripts/clone-elasticsearch/index.js --branch $branch | |
| - name: Run validation (Push) | |
| if: github.event_name == 'push' | |
| working-directory: ./clients-flight-recorder/scripts/types-validator | |
| env: | |
| BRANCH: ${{ github.ref_name }} | |
| run: node index.js --generate-report --ci --branch $BRANCH | |
| - name: Save JSON report | |
| if: github.event_name == 'push' | |
| uses: actions/cache/save@v4 | |
| with: | |
| path: ./clients-flight-recorder/recordings/types-validation/types-validation.json | |
| key: types-validation-json-${{ format('{0}-{1}', github.ref_name, github.sha) }} | |
| - name: Run validation (PR) | |
| if: github.event_name == 'pull_request' | |
| id: validation | |
| working-directory: ./elasticsearch-specification | |
| run: node .github/validate-pr --token ${{ secrets.GITHUB_TOKEN }} | |
| - name: Find existing comment | |
| if: github.event_name == 'pull_request' | |
| uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3.1.0 | |
| id: find-comment | |
| with: | |
| issue-number: ${{ github.event.pull_request.number }} | |
| comment-author: 'github-actions[bot]' | |
| body-includes: 'Following you can find the validation changes' | |
| - name: Create or update comment | |
| if: github.event_name == 'pull_request' | |
| uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| comment-id: ${{ steps.find-comment.outputs.comment-id }} | |
| issue-number: ${{ github.event.pull_request.number }} | |
| body: ${{ steps.validation.outputs.comment_body }} | |
| edit-mode: replace |