|
| 1 | +name: Index autocomplete Elasticsearch |
| 2 | + |
| 3 | +# **What it does**: Indexes autocomplete data into Elasticsearch. |
| 4 | +# **Why we have it**: So we can power the API for autocomplete. |
| 5 | +# **Who does it impact**: docs-engineering |
| 6 | + |
| 7 | +on: |
| 8 | + workflow_dispatch: |
| 9 | + schedule: |
| 10 | + - cron: '20 16 * * *' # Run every day at 16:20 UTC / 8:20 PST |
| 11 | + pull_request: |
| 12 | + paths: |
| 13 | + - .github/workflows/index-autocomplete-elasticsearch.yml |
| 14 | + - 'src/search/scripts/index/**' |
| 15 | + - 'package*.json' |
| 16 | + |
| 17 | +permissions: |
| 18 | + contents: read |
| 19 | + |
| 20 | +jobs: |
| 21 | + index-autocomplete-elasticsearch: |
| 22 | + if: ${{ github.repository == 'github/docs-internal' }} |
| 23 | + runs-on: ubuntu-20.04-xl |
| 24 | + steps: |
| 25 | + - name: Checkout |
| 26 | + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 |
| 27 | + |
| 28 | + - uses: ./.github/actions/node-npm-setup |
| 29 | + |
| 30 | + - uses: ./.github/actions/setup-elasticsearch |
| 31 | + if: ${{ github.event_name == 'pull_request' }} |
| 32 | + |
| 33 | + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 |
| 34 | + with: |
| 35 | + token: ${{ secrets.DOCS_BOT_PAT_READPUBLICKEY }} |
| 36 | + repository: github/docs-internal-data |
| 37 | + path: docs-internal-data |
| 38 | + |
| 39 | + - name: Check that Elasticsearch is accessible |
| 40 | + if: ${{ github.event_name == 'pull_request' }} |
| 41 | + run: curl --fail --retry-connrefused --retry 5 -I http://localhost:9200 |
| 42 | + |
| 43 | + - name: Run indexing |
| 44 | + env: |
| 45 | + ELASTICSEARCH_URL: ${{ github.event_name == 'pull_request' && 'http://localhost:9200' || secrets.ELASTICSEARCH_URL }} |
| 46 | + run: npm run index -- autocomplete docs-internal-data |
| 47 | + |
| 48 | + - uses: ./.github/actions/slack-alert |
| 49 | + if: ${{ failure() && github.event_name == 'schedule' }} |
| 50 | + with: |
| 51 | + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} |
| 52 | + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} |
0 commit comments