Skip to content

Github action to add/update a record in an Algolia index

License

Notifications You must be signed in to change notification settings

chuckmeyer/add-algolia-record

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Create or Update Algolia Index Record

A GitHub action to add or update a record in an Algolia index. Useful for building indices of Github objects like Issues or Pull Requests from events.

Usage

      - name: Add to index
        uses: ./.github/actions/add-index-record
        with:
          app_id: ${{ secrets.ALGOLIA_APP_ID }}
          api_key: ${{ secrets.ALGOLIA_API_KEY }}
          index_name: ${{ github.event.repository.name }}
          record: |
            {
              "title": "${{ github.event.issue.title }}", 
              "url": "${{ github.event.issue.html_url }}", 
              "labels": "${{ github.event.issue.labels }}",
              "objectID": "${{ github.event.issue.number }}"
            }

Action inputs

Name Description Required
app_id ID of this application in your Algolia account (best stored in a Github Secret). true
api_key API key with write permissions to the index in your Algolia account (best stored in a Github Secret). true
index_name Name of the Algolia index to write this record. true
record JSON record to write to this index as a string (see https://www.algolia.com/doc/guides/sending-and-managing-data/prepare-your-data/#algolia-records for details). true

Outputs

Outputs the ID of the created record object. Note that in order to read the step output the action step must have an id.

      - name: Add to index
        id: index_step
        uses: chuckmeyer/add-algolia-record@v0
        with:
          app_id: ${{ secrets.ALGOLIA_APP_ID }}
          api_key: ${{ secrets.ALGOLIA_API_KEY }}
          index_name: ${{ github.event.repository.name }}
          record: |
            {"title": "${{ github.event.issue.title }}", "url": "${{ github.event.issue.html_url }}", "labels": "${{ github.event.issue.labels }}",
             "objectID": "${{ github.event.issue.number }}"}
      - name: Check outputs
        run: |
          echo "Object ID - ${{ steps.index_step.outputs.object_id }}"

License

MIT

About

Github action to add/update a record in an Algolia index

Resources

License

Stars

Watchers

Forks

Packages

No packages published