@@ -230,21 +230,64 @@ jobs:
230230 FASTLY_SURROGATE_KEY : api-search:${{ matrix.language }}
231231 run : npm run purge-fastly-edge-cache
232232
233- - name : Alert on scraping failures
234- if : ${{ steps.check-failures.outputs.has_failures == 'true' && github.event_name != 'workflow_dispatch' }}
235- uses : ./.github/actions/slack-alert
233+ - name : Upload failures artifact
234+ if : ${{ steps.check-failures.outputs.has_failures == 'true' }}
235+ uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
236+ with :
237+ name : search-failures-${{ matrix.language }}
238+ path : /tmp/records/failures-summary.json
239+ retention-days : 1
240+
241+ - uses : ./.github/actions/slack-alert
242+ if : ${{ failure() && github.event_name != 'workflow_dispatch' }}
236243 with :
237244 slack_channel_id : ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }}
238245 slack_token : ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
239- message : |
240- :warning: ${{ steps.check-failures.outputs.failed_pages }} page(s) failed to scrape for general search indexing (language: ${{ matrix.language }})
241246
242- The indexing completed but some pages could not be scraped. This may affect search results for those pages.
247+ notifyScrapingFailures :
248+ name : Notify scraping failures
249+ needs : updateElasticsearchIndexes
250+ if : ${{ always() && github.repository == 'github/docs-internal' && github.event_name != 'workflow_dispatch' && needs.updateElasticsearchIndexes.result != 'cancelled' }}
251+ runs-on : ubuntu-latest
252+ steps :
253+ - name : Check out repo
254+ uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
255+
256+ - name : Download all failure artifacts
257+ uses : actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
258+ with :
259+ pattern : search-failures-*
260+ path : /tmp/failures
261+ continue-on-error : true
243262
244- Workflow: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
263+ - name : Check if any failures were downloaded
264+ id : check-artifacts
265+ run : |
266+ if [ -d /tmp/failures ] && [ "$(ls -A /tmp/failures 2>/dev/null)" ]; then
267+ echo "has_artifacts=true" >> $GITHUB_OUTPUT
268+ else
269+ echo "has_artifacts=false" >> $GITHUB_OUTPUT
270+ fi
245271
246- - uses : ./.github/actions/slack-alert
247- if : ${{ failure() && github.event_name != 'workflow_dispatch' }}
272+ - uses : ./.github/actions/node-npm-setup
273+ if : ${{ steps.check-artifacts.outputs.has_artifacts == 'true' }}
274+
275+ - name : Aggregate failures and format message
276+ if : ${{ steps.check-artifacts.outputs.has_artifacts == 'true' }}
277+ id : aggregate
278+ run : |
279+ RESULT=$(npx tsx src/search/scripts/aggregate-search-index-failures.ts /tmp/failures \
280+ --workflow-url "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}")
281+ {
282+ echo 'result<<EOF'
283+ echo "$RESULT"
284+ echo 'EOF'
285+ } >> "$GITHUB_OUTPUT"
286+
287+ - name : Send consolidated Slack notification
288+ if : ${{ steps.check-artifacts.outputs.has_artifacts == 'true' }}
289+ uses : ./.github/actions/slack-alert
248290 with :
249291 slack_channel_id : ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }}
250292 slack_token : ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
293+ message : ${{ fromJSON(steps.aggregate.outputs.result).message }}
0 commit comments