resource-published #535
This file contains 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: Search Ingest Trigger | |
on: | |
repository_dispatch: | |
types: | |
- resource-published | |
- resource-unpublished | |
jobs: | |
debug: | |
runs-on: ubuntu-latest | |
steps: | |
- run: | | |
echo "Status: ${{ github.event.client_payload.status }}" | |
echo "Path: ${{ github.event.client_payload.path }}" | |
search-ingest: | |
if: (github.event.client_payload.status == 200 || github.event.client_payload.status == 204) && endsWith(github.event.client_payload.path, '.md') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Sleep for 90 seconds assuming query-index-search.json will be updated before | |
run: sleep 90s | |
shell: bash | |
- name: Remove .md extension | |
id: removeMd | |
uses: frabert/replace-string-action@v2 | |
with: | |
pattern: '\.md$' | |
string: ${{ github.event.client_payload.path }} | |
replace-with: '' | |
- name: Build search endpoint | |
id: searchEndpoint | |
uses: frabert/replace-string-action@v2 | |
with: | |
pattern: '{{path}}' | |
string: ${{ github.event.client_payload.status == 200 && vars.SEARCH_API_INGEST_PATTERN || vars.SEARCH_API_DELETE_PATTERN }} | |
replace-with: ${{ steps.removeMd.outputs.replaced }} | |
- name: Trigger search API | |
uses: fjogeleit/http-request-action@v1 | |
with: | |
url: ${{ steps.searchEndpoint.outputs.replaced }} | |
method: 'POST' | |
timeout: 20000 | |
ignoreStatusCodes: '404' | |
failure-notification: | |
runs-on: ubuntu-latest | |
needs: search-ingest | |
if: failure() | |
steps: | |
- name: Notify Slack | |
uses: slackapi/[email protected] | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_NOTIFICATION_SEARCH_WEBHOOK }} | |
with: | |
payload: | | |
{ | |
"text": ":exclamation: Search ingest failed: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
} |