Skip to content
rss

GitHub Action

SlackFeedBot

v1.2.9 Latest version

SlackFeedBot

rss

SlackFeedBot

Push RSS feed updates to Slack via GitHub Actions

Installation

Copy and paste the following snippet into your .yml file.

              

- name: SlackFeedBot

uses: selfagency/[email protected]

Learn more about this action in selfagency/slackfeedbot

Choose a version

SlackFeedBot

Push RSS feed updates to Slack via GitHub Actions

Sample output

How to use this Action

  1. Add the Incoming Webhooks app to your Slack workspace if you haven't already.
  2. Create a new webhook by clicking the Add to Slack button.
  3. Customize the webhook however you like, then copy the webhook URL.

Sample configuration

  1. Create a new workflow in your desired repository (e.g. .github/workflows/slackfeedbot.yml) and drop in the follwing:
name: SlackFeedBot
on:
  schedule:
    - cron: '*/15 * * * *'
jobs:
  rss-to-slack:
    runs-on: ubuntu-latest
    steps:
      - name: NYT
        uses: 'selfagency/[email protected]'
        with:
          rss: 'https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml'
          slack_webhook: ${{ secrets.SLACK_WEBHOOK }}
          interval: 15

Options

Required fields denoted with *. Must specify cache_dir (which requires separate use of actions/cache or a similar solution) or interval.

  • rss*: The RSS feed URL.
  • feed_name: A title to override the RSS feed's own title.
  • feed_image: An image to override the RSS feed's default feed image.
  • slack_webhook*: The Slack webhook URL (this can and probably should be a repository or organization secret).
  • cache_dir*: The folder in which to cache feed data, which prevents publishing duplicates, or alternately...
  • interval*: The number of minutes between runs of the parent workflow, as specified in the cron section of the schedule workflow trigger (may publish duplicates due to post pinning).
  • unfurl: Shows the Open Graph preview for RSS items instead of this action's display format. Set to false because it's kind of flaky and non-customizable. Use the below settings instead to customize display.
  • show_desc: Show the post description. Defaults to true.
  • show_img: Show the post image. Defaults to true.
  • show_date: Show the post date. Defaults to true.
  • show_link: Show the Read more link, linking back to the post. Defaults to true.

Examples

With cache folder (recommended)

Hashes and caches the post title + creation date to ensure no duplicates are posted.

name: SlackFeedBot
on:
  schedule:
    - cron: '*/15 * * * *'
jobs:
  rss-to-slack:
    runs-on: ubuntu-latest
    steps:
      - name: Generate cache key
        uses: actions/github-script@v6
        id: generate-key
        with:
          script: |
            core.setOutput('cache-key', new Date().valueOf())
      - name: Retrieve cache
        uses: actions/cache@v2
        with:
          path: ./slackfeedbot-cache
          key: feed-cache-${{ steps.generate-key.outputs.cache-key }}
          restore-keys: feed-cache-
      - name: NYT
        uses: 'selfagency/[email protected]'
        with:
          rss: 'https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml'
          slack_webhook: ${{ secrets.SLACK_WEBHOOK }}
          cache_dir: './slackfeedbot-cache'

With interval

No cache, but maybe duplicates.

name: SlackFeedBot
on:
  schedule:
    - cron: '*/15 * * * *'
jobs:
  rss-to-slack:
    runs-on: ubuntu-latest
    steps:
      - name: NYT
        uses: 'selfagency/[email protected]'
        with:
          rss: 'https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml'
          slack_webhook: ${{ secrets.SLACK_WEBHOOK }}
          interval: 15

Multiple feeds

name: FeedBot
on:
  schedule:
    - cron: '*/15 * * * *'
jobs:
  rss-to-slack:
    runs-on: ubuntu-latest
    steps:
      - name: LAT
        uses: 'selfagency/[email protected]'
        with:
          rss: 'https://www.latimes.com/rss2.0.xml'
          slack_webhook: ${{ secrets.SLACK_WEBHOOK }}
          interval: 15
      - name: WaPo
        uses: 'selfagency/[email protected]'
        with:
          rss: 'https://feeds.washingtonpost.com/rss/homepage'
          slack_webhook: ${{ secrets.SLACK_WEBHOOK }}
          interval: 15